标签:enc public java param 解决 odi code out springmvc
数据经过后台时产生乱码
<form action="/r/e/t1" method="post">
<input type="text" name="name">
<input type="submit">
</form>
@PostMapping("/e/t1")
public String test1(String name, Model model){
System.out.println(name);
model.addAttribute("msg", name);
return "test";
}
通过springmvc提供的CharacterEncodingFilter字符过滤器解决
<filter>
<filter-name>encoding</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>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
标签:enc public java param 解决 odi code out springmvc
原文地址:https://www.cnblogs.com/pinked/p/12229401.html