2

所以这就是问题所在:

example.com:8080/txt/temp.txt

结果如下:

ÑÑ‚С¾ С½С¾С²Ñ‹С¹ Ñ„С°С¹С» 这是一个新文件

我尝试了什么:

glassfish-web.xml

<glassfish-web-app>
  <parameter-encoding default-charset="UTF-8"/>
</glassfish-web-app>

web.xml

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
    <init-param>
        <param-name>fileEncoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

在 domain/config/default-web.xml 添加到默认 servlet

    <init-param>
        <param-name>fileEncoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>

在 glassfish4/bin/asadmin 中 -jar 之后添加

-Dfile.encoding=UTF-8

没有结果。请帮我。

4

0 回答 0