1.<mvc:annotation-driven conversion-service="conversionService"/>
当配置上面时,会使用下面的配置选项,若上面的配置注释掉了,
则pring会系统生成DefaultAnnocation...,会使用默认的编码iso-199...使用中文时,会出现乱码,
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8"></constructor-arg>
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
<property name="webBindingInitializer">
<bean class="com.xy.tech.shopping.interceptors.CustomWebBinding" />
</property>
</bean>
2.设置拦截器,防止重复提交,setTokenInterceptor负责写入token
validTokenInterceptor负责读入token判断是否重复提交
<mvc:interceptors >
<!-- 需要设置token的页面拦截器 -->
<mvc:interceptor>
<mvc:mapping path="/**/*.htm"/>
<bean class="com.xy.tech.security.SetTokenInterceptor"/>
</mvc:interceptor>
<!-- 需要验证token的页面拦截器 -->
<mvc:interceptor>
<mvc:mapping path="/**/*.action"/>
<bean class="com.xy.tech.security.ValidTokenInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>