📄 deptupdateaction.java
字号:
package dept.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import dept.bo.DeptBo;
import dept.form.DeptForm;
import dept.vo.DeptBean;
public final class DeptUpdateAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String forward = "";
DeptForm deptForm=(DeptForm)form;
boolean flg = isTokenValid(request,true);
ActionErrors errors=checkForm(deptForm);
if(!errors.isEmpty()){
saveErrors(request,errors);
forward="DeptToUpdateAction";
return (mapping.findForward(forward));
}
if(flg){
DeptBean deptBean=new DeptBean();
//form--->bean
BeanUtils.copyProperties(deptBean,deptForm);
DeptBo deptBo=new DeptBo();
//插入
deptBo.updateDept(deptBean);
forward="DeptSelectAction";
}
return (mapping.findForward(forward));
}
public ActionErrors checkForm(DeptForm deptForm) {
ActionErrors errors = new ActionErrors();
if (deptForm.getDeptName()==null||"".equals(deptForm.getDeptName())||deptForm.getDeptName().length()>15) {
errors.add("deptName",new ActionError("input.error","deptName"));
}
if (deptForm.getDescription()==null||"".equals(deptForm.getDeptName())||deptForm.getDescription().length()>40) {
errors.add("description",new ActionError("input.error","description"));
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -