Web.xml中jsp-config元素简述
来源:互联网 发布:c语言中的enum 编辑:程序博客网 时间:2024/05/16 14:14
<jsp-config>包括<taglib>和<jsp-property-group>两个子元素。其中,<taglib>在jsp1.2就已经存在了,而<jsp-property-group>是jsp2.0增加的元素。
一、首先介绍一下taglib
taglib有两种配置方法,具体取决于web.xml开头出的文本类型声明,
a) 如果开头是下面这样的,
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
在web.xml中直接写<taglib>就可以了,如:
<taglib> <taglib-uri>controls</taglib-uri> <taglib-location>/WEB-INF/mycontrol.tld</taglib-location></taglib>
b) 如果开头是这样的
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
在web.xml中taglib需要卸载jsp-config标签中,如:
<jsp-config> <taglib> <taglib-uri>controls</taglib-uri> <taglib-location>/WEB-INF/mycontrol.tl</taglib-location> </taglib></jsp-config>
二、下面介绍一下jsp-property-group
先写一个例子,如下:
<jsp-config><taglib><taglib-uri>controls</taglib-uri><taglib-location>/WEB-INF/mycontrol.tld</taglib-location></taglib><jsp-property-group><description>JSP encoding example</description><display-name>JSP Configuration</display-name><url-pattern>*.jsp</url-pattern><el-ignored>true</el-ignored><page-encoding>GBK</page-encoding><scripting-invalid>false</scripting-invalid><include-prelude></include-prelude><include-coda></include-coda><description>html encoding example</description><display-name>JSP Configuration</display-name><url-pattern>*.html</url-pattern><el-ignored>true</el-ignored><page-encoding>GBK</page-encoding><scripting-invalid>false</scripting-invalid><include-prelude></include-prelude><include-coda></include-coda></jsp-property-group></jsp-config>
Jsp-property-group标签主要有一下8个属性:
1) <description>:设定的说明
2) <display-name>:设定名称
3) <url-pattern>:设定值所影响的范围,如/*.jsp
4) <el-ignored>:若为true,表示不支持EL语法
5) <scripting-invalid>:若为true,标识不支持<%scripting %>语法
6) <page-encoding>:设定jsp网页的编码
7) <include-prelude>:设置jsp网页的抬头,扩展名为.jspf,
如:<include-prelude>/jsp/segments/taglibs.jspf</include-prelude>
8) <include-coda>:设置jsp网页的结尾,扩展名为.jspf,
如:<include-prelude>/jsp/segments/coda.jspf</include-prelude>
解释:以上配置表明,在所有*.jsp和*.html的路径中都不能使用scriptlet(jsp脚本),因为这会是java代码和html代码混杂在一起,使项目可读性变弱,同时增加项目维护难度。
include-prelude设置每个文件的抬头为/jsp/segments/taglibs.jspf,include-prelude设置了每个文件的结尾/jsp/segments/coda.jspf,
记住,引入的文件必须是以.jspf为后缀的jsp插件框架文件。
通过引入抬头和结尾可以做一些标签申明和版权申明等类似工作。觉得很值得提倡!
- Web.xml中jsp-config元素简述
- web.xml中的jsp-config元素以及taglib元素
- web.xml中jsp-config标签
- web.xml中<jsp-config>的使用
- web.xml中的jsp-config元素以及由此想到的
- web.xml之jsp-config
- web.xml中的jsp-config
- web.xml <jsp-config>标签
- <jsp-config> in web.xml
- JSP web.xml <jsp-config>标签详解
- web.xml JSP <jsp-config>标签
- struts-config.xml 简述
- Web.config 相关内容简述
- struts-config.xml中元素的顺序
- struts-config.xml中元素的顺序
- JSP web.xml <jsp-config>标签使用详解
- JSP web.xml <jsp-config>标签使用详解
- JSP web.xml <jsp-config>标签使用详解
- Mybatis--XML映射文件
- 了解CSS/CSS3原生变量var
- 详解java类的生命周期
- 【基于url权限管理 shiro(二)】--权限管理解决方案
- gradle/maven/ant/之间关系的理解
- Web.xml中jsp-config元素简述
- Java对字符串进行的操作
- 图像分割 | FCN数据集制作的全流程(图像标注)
- Windows7系统如何禁用驱动程序签名强制
- 解析 “路漫漫其修远兮,吾将上下而求索”
- 2017年上半年重大黑客事件盘点
- POJ3281:Dining(最大流)
- JDK1.8 连接Access数据库
- MyBatis中if标签注意问题