struts2 中 JAVA 代码 获取表单中的数据

Action 类中

    继承 ActionSupport 类, 并且实现 ServletRequestAware, ServletResponseAware 两个接口

    public class BaseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware 

    {

     private static final long serialVersionUID = 1L;

     protected HttpServletRequest request;

     protected HttpServletResponse response;

            

        @Override

     public void setServletResponse(HttpServletResponse response)

     {

     this.response = response;

     }  

     @Override

     public void setServletRequest(HttpServletRequest request)

     {

     this.request = request;

     }

    }

    

你可能感兴趣的:(java,struts2,action)