The most complete process for processing garbled code in jsp does not require manual Transcoding
Taking the encoding format as an example of UTF-8
1, jsp page file encoding format, right-click in eclipse-properties-resource-text file encode modify the UTF-8
2.
<%@ page pageEncoding="UTF-8"%>
As above, the file storage format is used to store files and compile Chinese Characters
3.
<%@ page contentType="text/html; charset=UTF-8" %>
Jsp page decoding format
4. jsp pageInside
The browser decoding format. If this format is not set, you can set it in the browser.
5. Add a filter to web. xml in the wen project.
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
characterEncodingFilter
/*
Do not miss it. Otherwise, garbled characters may appear when there are other filters.
This is actually equivalent to the jsp page
request.setCharacterEncoding("UTF-8")response.setCharacterEncoding ("UTF-8")
6. Set the Port location in the server. xml file in tomcat
7, if the use of <% @ include file = "../footer. jsp" %> requires both sides of the encoding completely consistent, such as not one side of UTF-8, one side of the UTF-8