EmpPreAddAction.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:2k
源码类别:

Java编程

开发平台:

Java

  1. package StudyNote;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.apache.struts.action.Action;
  5. import org.apache.struts.action.ActionForm;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.ActionMapping;
  8. import javax.servlet.ServletContext;
  9. import javax.sql.DataSource;
  10. import java.sql.Connection;
  11. import java.sql.Statement;
  12. import java.sql.ResultSet;
  13. import java.sql.SQLException;
  14. import java.util.*;
  15. import javax.servlet.http.*;
  16. import org.apache.struts.action.ActionMessage;
  17. import org.apache.struts.action.ActionMessages;
  18. public final class EmpPreAddAction extends Action{  
  19. public ActionForward execute(
  20. ActionMapping mapping,
  21. ActionForm form,
  22. HttpServletRequest request,  
  23. HttpServletResponse response) throws Exception {
  24.         HttpSession session = request.getSession();
  25. Vector depList = new Vector();
  26.     ServletContext context = servlet.getServletContext();
  27. DataSource dataSource = 
  28. (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
  29.         DB db = new DB(dataSource);
  30.         
  31. String PageForward;
  32. ActionMessages errors = new ActionMessages();
  33.         
  34.     String username=(String)session.getAttribute(Constants.LOGIN_USERNAME_KEY);
  35. if (InterUser.GetUserGrade(db,username)!=1){
  36.             errors.add(ActionMessages.GLOBAL_MESSAGE,
  37.                            new ActionMessage("errors.accessDeny"));
  38. if (!errors.isEmpty()) {
  39. saveErrors(request, errors);
  40.   PageForward="toWrong";  
  41. }
  42. else{
  43. session.setAttribute(Constants.DEP_LIST_KEY,Dep.Search(db));
  44.   PageForward="toEmpAdd";  
  45.   saveToken(request);  //避免重复提交
  46.     }
  47.   db.close();
  48.     return (mapping.findForward(PageForward));
  49.   }
  50. }