Joke Collection Website - Blessing messages - Is the garbled java program related to the coding of the operating system on the server?

Is the garbled java program related to the coding of the operating system on the server?

This method is also related to the operating system. If no encoding is specified, the java program will adopt the system encoding, and it is recommended to set it to UTF-8 encoding.

Two methods to solve the garbled code:

DoGet method in 1.servlet:

string name = request . getparameter(“name“);

String name = new string (request. getparameter(“name ")). getBytes(“ISO8859- 1“),“utf-8“);

2. Use filters to solve the problem of garbled code.

Create a new filter file in the project.

Write the following code in the doFliter method:

Httpservlet requestreq = (httpservlet request) request;

3. Set the file encoding in the development tool eclipse:

1. Click the window.

2. Click Reference at the bottom of the list.

3. Click Workspace in the reference interface.

4. Click Other on the Tex file code on the right.

5. Select the corresponding code.

6. UTF 8 encoding is recommended.