偶原先的web.xml struts2的filter设置.
<
filter
>
<
filter-name
>
struts2
</
filter-name
>
<
filter-class
>
org.apache.struts2.dispatcher.FilterDispatcher
</
filter-class
>
</
filter
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
<
filter-mapping
>
<
filter-name
>
struts2
</
filter-name
>
<
url-pattern
>
*.action
</
url-pattern
>
</
filter-mapping
>
jsp页面:
<s:if test="message != null">
<span style="color:red"> <s:property value="message" /> </span>
</s:if>
运行后出现以下异常:
java.lang.NullPointerException
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:54)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
org.apache.jsp.input_jsp._jspx_meth_s_005fif_005f0(input_jsp.java:92)
org.apache.jsp.input_jsp._jspService(input_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
试了半天终于解决了,把web.xml struts2的filter的url-pattern该成/*,即所有请求都经过struts2的fillter处理,而不是只处理*.action.
估计使用struts2/webwork的标签要先经过filter处理才不会出错.