Linux Tomcat Chinese path is garbled

TOMCAT Chinese path garbled solution:

Add a property named URIEncoding to the Server.xml file, which is used to encode the URL passed by the get method in the HTTP request. The default URL encoding of tomcat for the get protocol is ISO-8859-1. This character set cannot directly support Chinese and other double-byte information, and the download link of Chinese files is carried out through the get protocol. The following explains how to modify the server.xml file in the conf folder in the Tomcat installation directory.

Open the conf/server.xml file. If you haven't modified this file, you should be able to find the following code in it:

 

<Connector port="8080" protocol="HTTP/1.1"
               maxThreads="150" connectionTimeout="20000" disableUploadTimeout="true"/>

This code specifies the port number and other information that Tomcat listens to HTTP requests. You can add an attribute here: URIEncoding, and set the attribute value to UTF-8, so that Tomcat will no longer process get in ISO-8859-1 encoding. ask. The changed code is as follows (the red part is the newly added code):

 

<Connector port="8080" protocol="HTTP/1.1"
               maxThreads="150" connectionTimeout="20000" disableUploadTimeout="true"
               URIEncoding="UTF-8"/>

  Next, prepare to test the effect of the changes.

 

The easiest way to test is to let Tomcat list the directories and files in the WEB program by itself. By default, Tomcat will not directly list the files and folders in the WEB program directory. However, we can modify the conf located in the installation directory. The web.xml in the folder enables it to support automatic listing of directories and files in WEB programs. 

Find the following code in the conf/web.xml file: , change the blue false in the following code to true, you can

 

<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>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

Change the attribute of the parameter listings to true, and Tomcat can automatically list the files and folders in a WEB program directory. 

This method is normal in the windows operating system, and further confirmation is required in linux

Look at the default encoding of linux (first confirm that there is a Chinese package). Command #locale, if it is different from the development environment, modify it.

The following is the version and encoding information of the LINUX server

Modify the default encoding of Linux

1. Modify the /etc/sysconfig/i18n file

LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

change into: 

LANG="zh_CN.GB18030"
SUPPORTED="zh_CN.GB18030:zh_CN:zh"
SYSFONT="latarcyrheb-sun16""
SYSFONTACM="8859-15"

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326315254&siteId=291194637