gpt4 book ai didi

java - JSP 页面上未显示区域字符

转载 作者:行者123 更新时间:2023-11-30 03:15:35 25 4
gpt4 key购买 nike

我已经通过 Maven Webapp 使用 Spring 进行了格式化,以具有英语和孟加拉语的本地化功能。我分别从英语和孟加拉语的属性文件加载页面所需的消息。如果我直接将字符添加到页面,它们就会正确呈现。另外,如果我在 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>

我做错了什么?如何解决这个问题?提前致谢。

最佳答案

我遇到了同样的问题,但技术略有不同(Stpring、Maven、Pug(以前的 Jade))。在我的 Controller 中添加这一行对我有用:

@RequestMapping(value="/", produces = "text/html;charset=UTF-8")

感谢this post .

希望对您有所帮助!

关于java - JSP 页面上未显示区域字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32731907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com