0
我有一個web應用程序使用Spring MVC,版本4.3.8.RELEASE。它保存Unicode字符不正確:Spring MVC顯示Unicode字符不正確
我已經檢查過很多觀點:
(1)在MySQL數據庫中,它是NVARCHAR,不是VARCHAR
(2)在pom.xml
,我添加
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
(3)在JSP頁面中,我添加
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
(4)內部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>
<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>
(5)在豆控制消息,我添加
<beans:bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<beans:property name="basename" value="META-INF/messages/messages"/>
<beans:property name="defaultEncoding" value="UTF-8"/>
</beans:bean>
(6)在ViewResolver的,我還用於添加屬性UTF- 8 ...
但是不成功。如何解決它?
這是我的項目:https://github.com/donhuvy/temp_unicode
首先,你可以嘗試使用ReloadableResourceBundleMessageSource類嗎?如果你想 –
我也可以爲'ReloadableResourceBundleMessageSource'添加配置,但是編譯錯誤,我可以與你共享一個工作配置。 –
您是否嘗試刪除org.springframework.web.filter.CharacterEncodingFilter? –