📄 regeistaction.java
字号:
package example.regeist;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import com.shsafe.common.database.DatabaseConnection;
import com.shsafe.common.database.DatabaseConnectionManager;
import example.common.dto.UserDTO;
import example.common.struts.CommonAction;
public class RegeistAction extends CommonAction {
public ActionForward init(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RegeistForm regeistForm = (RegeistForm)form;
regeistForm.setUserId("");
regeistForm.setPassword("");
regeistForm.setConfirmPassword("");
regeistForm.setPid("");
regeistForm.setSex("未知");
regeistForm.setTel("");
regeistForm.setFax("");
regeistForm.setAddress("");
regeistForm.setZipCode("");
regeistForm.setEmail("");
return (new ActionForward("/regeist/regeist.jsp"));
}
public ActionForward regeist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RegeistForm regeistForm = (RegeistForm) form;
DatabaseConnection connection = DatabaseConnectionManager
.getMyConnection();
RegeistDAO dao = new RegeistDAO(connection);
UserDTO userInfo = new UserDTO();
userInfo.setUserId(regeistForm.getUserId());
userInfo.setPassword(regeistForm.getPassword());
userInfo.setName(regeistForm.getName());
userInfo.setPid(regeistForm.getPid());
userInfo.setSex(regeistForm.getSex());
userInfo.setTel(regeistForm.getTel());
userInfo.setFax(regeistForm.getFax());
userInfo.setAddress(regeistForm.getAddress());
userInfo.setZipCode(regeistForm.getZipCode());
userInfo.setEmail(regeistForm.getEmail());
int count = dao.regeist(userInfo);
log.info(count + "条数据插入数据库");
if (count < 1) {
ActionMessages msg = new ActionMessages();
msg.add("all", new ActionMessage("regeist.failure"));
saveMessages(request, msg);
return mapping.findForward("failure");
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -