struts2 的 Action 实现了ServletRequestAware接口,但是获取不到HttpServletRequest对象实例
需要在struts.xml配置文件中对相应的action加上拦截器引用:[code="xml"][/code]
[quote]struts2 的 Action 实现了ServletRequestAware接口,但是获取不到HttpServletRequest对象实例 [/quote]
[color=blue]
[b]要实现接口方法:[/b][/color]
[code="java"] private ServletContext context;
public void setServletContext(ServletContext context) {
this.context = context;
} [/code]
[color=blue]
[b]另外确保你的interceptorStack中含有[/b][/color]
[code="xml"] [/code]
[color=blue][b]最后,是不是InterceptorStack中的在servletConfig前面的Interceptor,已经做出了转向,即直接返回了result,后续Interceptor不再被调用[/b][/color]