转载:http://blog.csdn.net/lichaohn/article/details/5583368

分类: XML JAVA JSP 492人阅读 评论(0) 收藏 举报

在当前应用系统的web.xml里加入jsp-config代码:

  1. <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">  
  2. <jsp-config>  
  3.     <jsp-property-group>     
  4.         <description>        
  5.             Special property group for JSP Configuration JSP example.     
  6.         </description>     
  7.         <display-name>JSPConfiguration</display-name>     
  8.         <url-pattern>*.jsp</url-pattern>     
  9.         <el-ignored>true</el-ignored>     
  10.         <page-encoding>GB2312</page-encoding>     
  11.         <scripting-invalid>false</scripting-invalid>     
  12.         <include-prelude></include-prelude>     
  13.         <include-coda></include-coda>     
  14.           
  15. <description>        
  16.             Special property group for JSP Configuration JSP example.     
  17.         </description>     
  18.         <display-name>JSPConfiguration</display-name>     
  19.         <url-pattern>*.html</url-pattern>     
  20.         <el-ignored>true</el-ignored>     
  21.         <page-encoding>GB2312</page-encoding>     
  22.         <scripting-invalid>false</scripting-invalid>     
  23.         <include-prelude></include-prelude>     
  24.         <include-coda></include-coda>  
  25.     </jsp-property-group>  
  26. </jsp-config>  
  27.   
  28. <welcome-file-list>  
  29.     <welcome-file>index.jsp</welcome-file>  
  30.     <welcome-file>index.html</welcome-file>   
  31. </welcome-file-list>     
  32.   
  33. ... ...  
  34.   
  35. </webapp>  





说明:<jsp-config>里的定义,就是通知当前应用服务器,当前应用系统下,所有的 .jsp, .html 文件,若是没有定义contentType="text/html;charset=gb2312" 时,就会采用预设的 "GB2312" 字符集去处理,如此,就不须要在每个 include 的档案第一行加上 contentType="text/html;charset=gb2312" 了。

注:

<jsp-config>标签使用详解

<jsp-config> 包括<taglib> 和<jsp-property-group> 两个子元素。
   
    其中<taglib>元素在JSP 1.2时就已经存在;而<jsp-property-group>是JSP 2.0 新增的元素。
    <jsp-property-group>元素主要有八个子元素,它们分别为:
   
    1.<description>:设定的说明;
    2.<display-name>:设定名称;
    3.<url-pattern>:设定值所影响的范围,如:/CH2 或 /*.jsp;
    4.<el-ignored>:若为true,表示不支持EL 语法;
    5.<scripting-invalid>:若为true,表示不支持<% scripting %>语法;
    6.<page-encoding>:设定JSP 网页的编码;
    7.<include-prelude>:设置JSP 网页的抬头,扩展名为.jspf;
    8.<include-coda>:设置JSP 网页的结尾,扩展名为.jspf。

tomcat 5中include页面乱码问题

  1. <?xml version="1.0" encoding="ISO-8859-1"?>  
  2. <web-app 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"  
  5. version="2.4">  
  6.   
  7. <jsp-config>  
  8. <jsp-property-group>  
  9. <description>Special property group for JSP Configuration JSP example.</description>  
  10. <display-name>JSPConfiguration</display-name>  
  11. <url-pattern>*.jsp</url-pattern>  
  12. <el-ignored>true</el-ignored>  
  13. <page-encoding>GBK</page-encoding>  
  14. <scripting-invalid>false</scripting-invalid>  
  15. <include-prelude></include-prelude>  
  16. <include-coda></include-coda>  
  17.   
  18. <description>Special property group for JSP Configuration JSP example.</description>  
  19. <display-name>JSPConfiguration</display-name>  
  20. <url-pattern>*.html</url-pattern>  
  21. <el-ignored>true</el-ignored>  
  22. <page-encoding>GBK</page-encoding>  
  23. <scripting-invalid>false</scripting-invalid>  
  24. <include-prelude></include-prelude>  
  25. <include-coda></include-coda>  
  26. </jsp-property-group>  
  27. </jsp-config>  
posted on 2012-09-25 15:39  竹林后生  阅读(312)  评论(0编辑  收藏  举报