web.xml <jsp-config>标签
2014-02-11 10:28
387 查看
web.xml <jsp-config>详解
<jsp-config> 包括<taglib> 和<jsp-property-group> 两个子元素。其中<taglib>元素在JSP 1.2时就已经存在;而<jsp-property-group>是JSP 2.0 新增的元素。
这种情况主要用于版本更新管理配置:
打个比方,c.tld标签库也许要经常更新版本(没准过段时间就是c1.0.tld,
再过段时间就成c2.0.tld).如果我直接写在jsp里<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"%>。
如果要更新最新的标签库, 那我每次都要改写jsp代码,这样使得代码和引用tld文件耦合度太高了。
而如果在web.xml里写<taglib>
<taglib-uri>/WEB-INF/tlds/c.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
</taglib>
那么每次版本更新了,我只要更改web.xml里面的代码如下就行了:
<taglib>
<taglib-uri>/WEB-INF/tlds/c.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/c2.0.tld</taglib-location>
</taglib>
jsp里面代码不用任何改变,这样就降低了代码和tld文件的耦合程度,便于维护和迁移。
<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。
一个简单的<jsp-config>元素完整配置:
<jsp-config>
<taglib>
<taglib-uri>Taglib</taglib-uri>
<taglib-location>/WEB-INF/tlds/MyTaglib.tld</taglib-location>
</taglib>
<jsp-property-group>
<description>Special property group for JSP Configuration JSP example.</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>/jsp/* </url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>GB2312</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/include/prelude.jspf</include-prelude>
<include-coda>/include/coda.jspf</include-coda>
</jsp-property-group>
</jsp-config>
相关文章推荐
- JSP web.xml <jsp-config>标签使用详解
- web.xml JSP <jsp-config>标签
- JSP web.xml <jsp-config>标签使用详解
- JSP web.xml <jsp-config>标签使用详解
- How to configure spring boot through annotations in order to have something similar to <jsp-config> in web.xml?
- web.xml中<jsp-config>配制详解
- JSP 2.0 web.xml不再直接支持<taglib>标签配置
- web.xml中<jsp-config>的使用
- JSP 2.0 web.xml不再直接支持<taglib>标签配置
- JSP web.xml <jsp-config>标签使用详解
- tomcat源码之处理web.xml中<load-on-startup>标签
- <taglib>标签在web.xml文件中报错解决方法
- <Web> jsp:EL表达式+C标签
- web.xml中配置<error-page>标签不起作用的问题
- web.xml标签<context-param>的说明
- Web.xml配置<taglib>标签报错问题(cvc-complex-type.2.4.a: Invalid content was found starting with element 'tag
- web.xml配置文件中标签<listener-class>报错
- web.xml中配置<error-page>标签不起作用的问题
- web.xml中配置访问资源URL<url-pattern>/</url-pattern>时无法访问.html、.jsp、.js、.css等静态资源时的解决方案
- web.xml中配置<error-page>标签