日期:2014-05-16  浏览次数:20356 次

jsp include 乱码问题的解决

jsp include 乱码问题的解决
jsp include 的文件有时候会出现乱码,经过测试发现如下方法可以修改。
第一种情况可以修改被include的文件:
1.当jsp include动态文件时(jsp文件)可以在被include的jsp文件头部加上代码:

java 代码
  1. <%@?page?language= "java" ?contentType= "text/html;?charset=UTF-8" ??pageEncoding= "UTF-8" %>??

2.当jsp include静态文件时(html文件)可以在被include的html文件的<head></head>标签内加上代码:

xml 代码
  1. < meta ? http-equiv = "Content-Type" ? content = "text/html;?charset=UTF-8" ? /> ??

第二种情况不能够修改被include的文件:
此时可以修改tomcat的web.xml达到目的

xml 代码
  1. <? xml ? version = "1.0" ? encoding = "UTF-8" ?> ??
  2. < web-app ? version = "2.4" ? xmlns = "http://java.sun.com/xml/ns/j2ee" ??
  3. ???? xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" ??
  4. ???? xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee ??
  5. ????http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > ??
  6. ??
  7. ???? < jsp-config > ??
  8. ???????? < jsp-property-group > ??
  9. ???????????? < description > ??
  10. ????????????????Special?property?group?for?JSP?Configuration?JSP ??
  11. ????????????????example. ??
  12. ???????????? </ description > ??
  13. ???????????? < display-name > JSPConfiguration </ display-name > ??
  14. ???????????? < url-pattern > *.jsp </ url-pattern > ??