【发布时间】:2015-12-20 07:38:54
【问题描述】:
我已使用 Spring 的 Maven Webapp 进行格式化,以具有英语和孟加拉语的本地化功能。我分别从英语和孟加拉语的属性文件加载页面所需的消息。如果我直接将字符添加到页面,它们会正确呈现。此外,如果我在 unicode(例如:স)中添加孟加拉语字符,它们会正确显示。但由于属性文件不容易读取,我在普通孟加拉语文本中添加了文本(例如:স),但现在它们无法正确显示。它们显示为“à¦à¦¦à§à¦”等。
在每个 JSP 页面中,我都有以下内容。
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
在我的 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>
我也有,
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
在我的 spring-servlet.xml 中
<bean id="messageSourceLocale"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages.messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
我做错了什么?如何解决这个问题?提前致谢。
【问题讨论】:
标签: java spring jsp maven utf8-decode