在struts2的action中想要获得ServletConfig对象和pageContext对象,但是找了很多都没有答案...求解!

解决方案 »

  1.   

    Struts2的Action获取ServletConfig对象的解决方案
      

  2.   

    1 楼主的结贴率为什么能超过100%
    2 struts2里没有servlet你get ServletConfig干嘛用是ServletContext吧
    2 1)直接访问 org.apache.struts2.ServletActionContext. getPageContext()
                org.apache.struts2.ServletActionContext.getServletContext()
      2)模拟访问
                 ActionContext.getContext().getApplication();//ServletContext
                  ActionContext.getContext();//模拟pageContext