阿洵

springmvc-提交数据出现乱码

原因

页面表单提交方式为post

1 <form action="${pageContext.request.contextPath}/role/save"
2                 method="post">

解决方法

在web.xml配置《解决乱码的过滤器》然后指定内容编码关系

复制代码
 1 <!--解决乱码的过滤器-->
 2 <filter>
 3     <filter-name>CharacterEncodingFilter</filter-name>
 4     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
 5 <!--   内容编码关系-->
 6     <init-param>
 7         <param-name>encoding</param-name>
 8         <param-value>UTF-8</param-value>
 9     </init-param>
10 </filter>
11   <filter-mapping>
12       <filter-name>CharacterEncodingFilter</filter-name>
13 <!--      所有的请求都通过这里-->
14       <url-pattern>/*</url-pattern>
15   </filter-mapping>
复制代码

 

 


posted on   阿洵  阅读(65)  评论(0编辑  收藏  举报

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示