Home > Java > javaTutorial > body text

How to solve the garbled jsp source file

(*-*)浩
Release: 2020-09-19 13:30:19
Original
7862 people have browsed it

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:

Copy after login

By the way, set it:

<meta>
Copy after login

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");
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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!

Related labels:
jsp
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template