当前位置: 代码迷 >> Java Web开发 >> JSP页面包孕HTML页面,中文乱码
  详细解决方案

JSP页面包孕HTML页面,中文乱码

热度:8299   发布时间:2013-02-25 21:12:43.0
JSP页面包含HTML页面,中文乱码
JSP页面:

HTML code
<%@ page contentType="text/html; charset=utf-8" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">   <head>      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />   </head>   <body>      <%@include file="header" %>   </body></html>


HTML 页面:
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />  </head>  <body>     内容部分.......  </body> </html>



这是关联的2个页面的头部代码,网上也查了,可还是没能解决中文乱码问题,望大家帮忙看下

------解决方案--------------------------------------------------------
在web.xml里面加入代码
<!-- 控制jsp:include的编码 -->
<jsp-config>
<jsp-property-group>
<description>
Special property group for JSP Configuration HTML
example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
</jsp-property-group>
</jsp-config>


------解决方案--------------------------------------------------------
你可以设置一下:windows--》Preferences下的--》WEB---》JspFiles弹出一个新的对话框--》在endcoding中选择--》utf-8可以试一试;
  相关解决方案