Spring MVC UTF-8 編碼
問題:
問題:問題:
解決方案:
<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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
註冊的Charac terEncodingFilter:
<Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8" />
在Tomcat的server.xml中設定URIEncoding:
如果您使用Tomcat,請確保在server.xml 中將URIEncoding 設定為UTF-8:
return new ModelAndView("home", "utftest", "\u00f6lm");
以上是如何解決Spring MVC中的UTF-8編碼問題?的詳細內容。更多資訊請關注PHP中文網其他相關文章!