1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%>2 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">3 <HTML>4 <Head>5 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">6 </Head>7 <Body>8 9 </Body>Ten </HTML>
Use contenttype and pageencoding to set the difference between encodings:
- Pageencoding refers to the encoding of the JSP file itself, while the CharSet in ContentType refers to the content encoding that the server sends to the client.
- In JSP, if pageencoding exists, then the encoding of the JSP will be determined by pageencoding, otherwise it will be determined by the CharSet attribute in ContentType, and if neither is present, iso-8859-1 encoding will be used.
- In the JSP, everything has to go through two encoding operations, the first phase will use Pageencoding encoding, the second phase will use UTF-8 encoding, the third stage is Tomcat generated Web page, at this time is the use of ContentType.
JSP settings File encoding