struts1的配置文件

阅读更多

1.配置struts1时,需要在web.xml中配置相关信息:

 



  
    action
    org.apache.struts.action.ActionServlet
    
      config
      /WEB-INF/struts-config.xml
    
    
      debug
      3
    
    
      detail
      3
    
    0
  
  
    action
    *.do
  
  
    index.jsp
  
  
  
    
        java.lang.Throwable
        /common/500.jsp
    
    
        500
        /common/500.jsp
    
    
        404
        /common/404.jsp
    
    
        403
        /common/403.jsp
      
    
      
	    DB2 Connection  
	    jdbc/DW  
	    javax.sql.DataSource  
	    Container  
	
	








 

2.此外,struts.xml的配置如下:

 






  
  
  	 
 		
 		
	
  
  
  
  
  		
  		
  
  
  

   
      
      
      
      
      
      
      
   
   
   
      
      
      
      
   
   
  
  
  


3.其中的Action继承的是DispatchAction,当访问时,url为contentPath + wbgy.do?method=getAllWBGYXX。以下是action中的一个method对应的方法:

 

public ActionForward getAllWBGYXX(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		List WBGYList = new ArrayList();
		HttpSession session = request.getSession();
		FgyjdaRsQxYh user = (FgyjdaRsQxYh)session.getAttribute("user");
		int qx = (Integer)session.getAttribute("qx");
		String param ="";
		if(qx==3){//本人
			param =" where LRRZYBM='"+user.getZybm()+"'";
		}else if(qx==6){//本部门
			param =" where LRRBMDM="+user.getBmdm()+" and fydm="+user.getFydm();
		}
		WBGYList = wbgyServer.getAllWBGY(param);	
		if(XXX){
			request.setAttribute("WBGYList", WBGYList);
			return mapping.findForward("WBGYList");
		}else{
			return mapping.findForward("error");
		}
	}

 

4.需要添加相应的方法只需要增加相应的method方法,转发url的name,根据name重新跳转页面:

public ActionForward getAllWBGYXX(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
	//业务处理
	return mapping.findForward("xxx");
}

 5.相关跳转的信息在struts.xml中配置。

你可能感兴趣的:(struts1,dispatchAction)