package cn.mldn.emp.action;import java.util.List;import cn.mldn.emp.factory.EmpDAOFactory;
import cn.mldn.emp.vo.Emp;import com.opensymphony.xwork2.ActionSupport;public class EmpAction extends ActionSupport {
private List<Emp> all; //雇员列表
private Emp emp; //雇员
private int empno; //雇员编号(主键)
private String keyword; //关键字 public String getKeyword() {
return keyword;
} public void setKeyword(String keyword) {
this.keyword = keyword;
} public int getEmpno() {
return empno;
} public void setEmpno(int empno) {
this.empno = empno;
} public Emp getEmp() {
return emp;
} public void setEmp(Emp emp) {
this.emp = emp;
} public List<Emp> getAll() {
return all;
}
public void setAll(List<Emp> all) {
this.all = all;
}
/**显示、查询所有雇员列表*/
public String findAll()throws Exception{
all=EmpDAOFactory.getIEmpDAOInstance().findAll(keyword);
return "all";
}
/**跳转到添加雇员页面*/
public String insert(){
return "insert";
}
/**添加雇员*/
public String doInsert()throws Exception{
EmpDAOFactory.getIEmpDAOInstance().doInsert(emp);
all=EmpDAOFactory.getIEmpDAOInstance().findAll(keyword); //添加成功后立刻查询全部跳转到列表页面。
return "list";
}
/**删除雇员信息
* @throws Exception */
public String doDelete() throws Exception{
EmpDAOFactory.getIEmpDAOInstance().doDelete(empno);
all=EmpDAOFactory.getIEmpDAOInstance().findAll(keyword);
return "list";
}
/**跳转到更新雇员信息页面
* @throws Exception */
public String update() throws Exception{
emp=EmpDAOFactory.getIEmpDAOInstance().findById(empno);
return "update";
}
/**更新雇员信息
* @throws Exception */
public String doUpdate() throws Exception{
EmpDAOFactory.getIEmpDAOInstance().doUpdate(emp);
all=EmpDAOFactory.getIEmpDAOInstance().findAll(keyword); //添加成功后立刻查询全部跳转到列表页面。
return "list";
}
}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="emp" extends="struts-default" namespace="/Emp">
<action name="emp_*" method="{1}" class="cn.mldn.emp.action.EmpAction">
<result name="all">/emp_list.jsp</result>
<result name="insert">/doInsert.jsp</result>
<result name="update">/doUpdate.jsp</result>
<result name="list" type="redirect">/Emp/emp_findAll</result><!-- 防止增、删、改、查重复提交 -->
<result name="input">/doInsert.jsp</result>
</action>
</package>
</struts>
只对doInsert(),doUpdate()方法进行校验怎么完成?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货