在通过maven方式导入strust2依赖之后,(在pom.xml中引入strust和tomcat的),写在dependencies标签中
javax.servlet javax.servlet-api4.0.1 provided org.apache.struts struts2-core2.5.13
在项目的web.xml中,配置strust的过滤器
struts2 org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter struts2 public abstract class baseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware,ModelDriven { protected HttpServletResponse response; protected HttpServletRequest request; protected HttpSession session; protected ServletContext application; protected final static String SUCCESS = "success"; protected final static String FAIL = "fail"; protected final static String LIST = "list"; protected final static String TOEDIT = "toEdit"; protected final static String TOLIST = "toList"; protected Object result; protected Object msg; protected int code; public Object getResult() { return result; } public Object getMsg() { return msg; } public int getCode() { return code; } @Override public void setServletResponse(HttpServletResponse arg0) { this.response = arg0; } @Override public void setServletRequest(HttpServletRequest arg0) { this.request = arg0; this.session = arg0.getSession(); this.application = arg0.getServletContext(); } }
baseAction,定义了一些返回值常量,避免因编码产生的错误。并且实现了ServletRequestAware,ServletResponseAware,ModelDrive接口,方便使用。



