Home > Java > JavaBase > Java web page garbled solution

Java web page garbled solution

Release: 2019-11-23 10:00:27
Original
2076 people have browsed it

Java web page garbled solution

Common places where java web pages are garbled are as follows:

In the jsp page. EL expressions or direct values, even if you write a fixed Chinese display, it will be messy.

java code. The value transmitted from front end to back end is garbled.

jsp page encoding.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
Copy after login

Anyone who writes jsp is familiar with changing the character set of the page.

java background code.

If it is a java web project, you can set the encoding format when obtaining values ​​in post and get methods.

POST method

request.setCharacterEncoding("utf-8");
Copy after login

GET method

request.setCharacterEncoding("utf-8");
//例如获取页面的username值进行转换
String username =new String(request.getParameter("username").getBytes("iso8859-1"),"utf-8");
Copy after login

For more java knowledge, please pay attention to java basic tutorial.

The above is the detailed content of Java web page garbled solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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