防止表单重复提交使用s:token发现action中无法获取值
如果把相关的<s:token/>等关于重复提交的配置 去掉就会一切正常,
一加上Action所有的属性全部为空. 诊对这个问题,如果加上其它的拦截器如token的拦截器,
那么struts2.3.16默认的拦截器 不会被执行,而为Action中的对象赋值刚好是默认拦截器的功能.
因此解决方法就是我们在配置过struts2.3.16重复提交的拦截器功能后还要手动的配置一下
默认的拦截器,否则前台页面提交的东西就不能自动的为Action进行赋值
解决方法:
<?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>