struts2调试技巧



struts2调试技巧。

1.设置开发模式为调试模式:

    将struts.properties文件下的devMode=false 改为 devMode=true

2.增加调试包:struts2-config-browser-plugin-2.0.11.1.jar拷贝到lib文件夹下

   然后在浏览器中浏览地址:http://localhost:8080/pub/config-browser/index.action

3.调试使用的标签:<s:debug />

4.在URL上增加调试命令:

   http://localhost:8080/pub/Login/login!login.action?debug=xml

 

 

 

 struts的配置文件:

web.xml:


struts.xml:

struts.properties:

 

struts2访问Application,session,Request:

     HttpServletRequest req = ServletActionContext.getRequest();

     HttpSession session = req.getSession();

     session.setAttribute(“username”,username);

或者

     Map sessionMap = ActionContext.getContext().getSession();

     sessionMap.put(“username”,”change the username”);

 

     Map applicationMap = ActionContext.getContext().getApplication();