异常代码形式:
严重: Exception occurred during processing
request: null
java.lang.NullPointerException
at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:630)
at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:606)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:210)
at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:139)
at
org.apache.struts2.interceptor.TokenInterceptor.getErrorMessage(TokenInterceptor.java:182)
at
org.apache.struts2.interceptor.TokenInterceptor.handleInvalidToken(TokenInterceptor.java:166)
at
org.apache.struts2.interceptor.TokenInterceptor.handleToken(TokenInterceptor.java:151)
at
org.apache.struts2.interceptor.TokenInterceptor.doIntercept(TokenInterceptor.java:142)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)
at
java.lang.Thread.run(Thread.java:662)
异常原因:
(1)如果把相关的<s:token/>等关于重复提交的配置
去掉就会一切正常,
一加上Action所有的属性全部为空.
诊对这个问题,如果加上其它的拦截器如token的拦截器,
那么struts2.3.16默认的拦截器
不会被执行,而为Action中的对象赋值刚好是默认拦截器的功能.
因此解决方法就是我们在配置过struts2.3.16重复提交的拦截器功能后还要手动的配置一下
默认的拦截器,否则前台页面提交的东西就不能自动的为Action进行赋值
struts.xml的代码:
<?xml version="1.0" encoding="UTF-8"
?>
<!DOCTYPE struts
PUBLIC
"-//Apache
Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="struts"
extends="struts-default" >
<action
name="login" class="action.LoginAction">
<interceptor-ref
name="defaultStack"></interceptor-ref>
<interceptor-ref
name="token"></interceptor-ref>
<result
name="invalid.token">/error.jsp</result>
<result name="success"
type="dispatcher">
<param
name="location">/login.jsp</param>
</result>
</action>
</package>
</struts>
同时要注意两点问:(1)自己写的Action类一点要继承ActionSupport。
(2)表单内部要加上<s:token></s:token>标签。
struts2.3.16中表单重复提交出现空指针异常,布布扣,bubuko.com