gpt4 book ai didi

java - JSP 不显示西里尔文内容?

转载 作者:行者123 更新时间:2023-11-28 22:47:32 24 4
gpt4 key购买 nike

当我使用 RequsetDispatcher 运行 JSP 页面时,它会显示带有“????...”的西里尔文内容。

RequestDispatcher view = request.getRequestDispatcher("/view.jsp");

这是我尝试过的:

我正在使用 Apache Tomcat,我在 VM 选项中添加了它:

-Dfile.encoding=UTF-8

在jsp文件的开头:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

在 web.xml 中:

<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>utf-8</page-encoding>
</jsp-property-group>
</jsp-config>

<filter>
<filter-name>CharSet</filter-name>
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CharSet</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

在tomcat配置文件conf/server.xml中的connectors中:

 URIEncoding="UTF-8" 

它仍然不起作用。有什么解决办法吗?

编辑:修复了我在 Servlet 方法中添加 response.setCharacterEncoding("UTF-8"); 时的问题。

最佳答案

看来您的问题很可能与您使用的应用服务器有关。

请引用此线程并尝试通过将应用程序服务器配置文件更改为使用 UTF-8 来解决您的问题 -> How to get UTF-8 working in Java webapps

关于java - JSP 不显示西里尔文内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53578919/

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