我用Spring对Maven Webapp进行了格式化,使其具有英语和孟加拉语的本地化功能。我分别为英语和孟加拉语从属性文件加载页面所需的消息。如果我直接将字符添加到页面中,它们将被正确地呈现。另外,如果我在unicode (Ex:স)中添加孟加拉字符,它们将得到正确的显示。但是,由于属性文件无法轻松读取,所以我以普通孟加拉文本(Ex:স)添加了文本,但现在它们无法正确显示。它们被显示为“需要帮助、需要”等等。
在每个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>在我的Springservlet.xml中
<bean id="messageSourceLocale"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages.messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>我做错了什么?怎么解决这个问题?提前谢谢。
发布于 2016-06-09 09:27:10
我在不同的技术(Stpring,Maven,Pug(以前的Jade))上也有同样的问题。在我的Controller中添加这一行对我是有用的:
@RequestMapping(value="/", produces = "text/html;charset=UTF-8")多亏了this post。
希望那会有帮助!
https://stackoverflow.com/questions/32731907
复制相似问题