Solution to java displaying garbled characters:
1. The browser calls jsp, html and other pages display garbled characters in Chinese
This situation needs to meet two requirements:
(1) The file itself is edited and saved in utf-8 (right click on the properties in myEclipse and select utf-8)
(2 ) The browser uses utf-8 to parse:
(manual)==> Right-click in the browser and select the encoding format as utf-8
(smart)==> Write in the file For example: Use the tag to simulate the response header, which tells the browser to use UTF-8 encoding and parsing
(Smart)==> response.setContentType("text/html;charset=UTF-8"); tells the browser to use UTF-8 encoding analysis
Commonly used:
<meta name="content-type" content="text/html; charset=UTF-8">或<meta charset="utf-8"> <%@ pageEncoding="utf-8"%> <?xml encoding="UTF-8"?>
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of Solution to garbled code displayed in java. For more information, please follow other related articles on the PHP Chinese website!