contentType、pageEncoding、content中编码的区别
时间:2010-12-21 来源:lingxue3769
<% @ page contentType = " text/html; charset=UTF-8 " pageEncoding = " UTF-8 " %>
< meta http-equiv ="Content-Type" content ="text/html; charset=UTF-8" >
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
等效:
<%@ page contentType="text/html; content-type="text/html;charset=UTF-8""%>
不过content-type优先级高点
1.jsp页面编码需要
2.serlvet引擎在翻译jsp页面时会吧jsp转换为servlet代码; 而上面代码会翻译成: response.setContentType("text/html;charset=UTF-8");
<meta... content-type= ..> 浏览器翻译, 有了这个浏览器就知道html用什么编码展现给用户了.
没有这句, 浏览器就默认用response.setContentType设置的编码
<meta... content-type= ..>优先级最高, <%@ content-type...%>第二, <%@ pageEncoding %>第三
相关阅读 更多 +
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-