Home  >  Article  >  Java  >  How to solve the garbled jsp source file

How to solve the garbled jsp source file

(*-*)浩
(*-*)浩Original
2019-05-20 14:12:167866browse

This article will introduce several ways to solve the problem of garbled JSP files. The details are as follows. I hope it will be a reference for everyone.

How to solve the garbled jsp source file

Check whether the encoding format is set in the jsp file header:


By the way, set it:

<meta>

View the encoding format of the project: set to UTF-8

project–》properties:

How to solve the garbled jsp source fileIf the jsp file is copied directly, you should also check it, right-click the jsp File, select properties, and set the encoding format:

How to solve the garbled jsp source fileThe above generally solves the problem of garbled Chinese characters on the page itself. If there are still problems, such as garbled characters in the submitted form, etc., you need to respond in the request header. Header setting encoding:

 //设置编码格式
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");

4. If the garbled code has not been solved in the end, set the tomcat server encoding format. By default, the encoding method used by tomcat: iso8859-1, open the setting.xml file ( (In the tomcat folder conf) Find the following code:

<connector></connector>

This code specifies the port number and other information for Tomcat to listen to HTTP requests.
You can add an attribute here: URIEncoding. Set the attribute value to UTF-8 to allow Tomcat (default ISO-8859-1 encoding) to process get requests in UTF-8 encoding.

<connector></connector>

Related learning recommendations: java basics

The above is the detailed content of How to solve the garbled jsp source file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use jsp buttonNext article:How to use jsp button