ServletActionContext的getAction方法返回null
我正在使用servlet过滤器,试图获取与当前请求相关联的操作.
I am using a servlet filter where I am trying to get the action associated with the current request.
我的过滤器的相关部分:
Relevant sections of my filter:
private ServletContext context;
public void init(FilterConfig config) throws ServletException {
this.context = config.getServletContext();
}
protected void doFilter(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws IOException, ServletException {
ServletActionContext actionContext = new ServletActionContext(context, request, response);
Action action = actionContext.getAction();
// action == null
}
我的问题是action
最终为空.这两个上下文变量都填充了一个值,但是由于某种原因,它找不到该动作.有任何想法吗?谢谢!
My problem is that action
ends up being null. Both of the context variables get populated with a value, but for some reason it cant find the action. Any ideas? Thanks!
ServletActionContext已初始化,并且在控件通过ActionServlet传递时正确填充了所有必需的变量.
ServletActionContext are initialised and all required variable are filled properly when control pass through ActionServlet.
在执行ActionServlet之前执行过滤器,并且在过滤器方法中创建对象未设置Action
Filter are executed before ActionServlet and and Creating object in filter method doesnt set Action
这是主要原因,因为ServletActionContext的某些getter方法未通过ActionServlet并因此未初始化所有属性,因此返回空值.
That is the main reason because of that some getter method of ServletActionContext returns null values because it doesn't gone through ActionServlet and hence all properties are not initialised.