springmvc----中文乱码解决

版权声明:原创文章,相互提高。 https://blog.csdn.net/xu1916659422/article/details/77461548

这两天敲例子的时候,后台接收前台中文,后台显示乱码,网上搜了好多例子。这里也记录一下,省的以后找半天。

加入配置前


后台

这种情况,只需要在web.xml中配置编码过滤器就行,

  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


加入该配置后

提交到后台以后不在是乱码了。








猜你喜欢

转载自blog.csdn.net/xu1916659422/article/details/77461548
今日推荐