解决taglib在servlet2.4和jsp2.0下写入web.xml的问题
2008-02-21 12:18
726 查看
注意:如果所建项目是servlet2.4的,那么在web.xml中写taglib就要加一个
<jsp-config>标记,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
TagStudy2
</display-name>
<jsp-config>
<taglib>
<taglib-uri>/hello</taglib-uri>
<taglib-location>/WEB-INF/HelloTag.tld</taglib-location>
</taglib>
</jsp-config>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
从servlet2.4开始,taglib的uri是在标签库描述符中(tld)指定的,就像下面:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag
Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>bean</shortname>
<uri>http://jakarta.apache.org/struts/tags-bean</uri>
任何需要使用这个标签库的页面都可以通过下面的页面级指令来引用它。标签库不需要再在web.xml文件中引用:
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
下面一个表是struts标签的uri:
sturts标签的可以直接通过uri引用,也可以通过在web.xml中声明再使用。直接通过uri引用,则不再需要tld文件,如果是web.xml的话,灵活性比较大,uri以后改变的话,只需要在web.xml中改变,不用在其他页面中改变。
<jsp-config>标记,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
TagStudy2
</display-name>
<jsp-config>
<taglib>
<taglib-uri>/hello</taglib-uri>
<taglib-location>/WEB-INF/HelloTag.tld</taglib-location>
</taglib>
</jsp-config>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
从servlet2.4开始,taglib的uri是在标签库描述符中(tld)指定的,就像下面:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag
Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>bean</shortname>
<uri>http://jakarta.apache.org/struts/tags-bean</uri>
任何需要使用这个标签库的页面都可以通过下面的页面级指令来引用它。标签库不需要再在web.xml文件中引用:
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
下面一个表是struts标签的uri:
Table 2-1. Struts 标签库URI | ||
Tag library | Struts 1.1 URI | Struts 1.2 URI |
struts-bean | http://jakarta.apache.org/struts/tags-bean | http://struts.apache.org/tags-bean |
struts-html | http://jakarta.apache.org/struts/tags-html | http://struts.apache.org/tags-html |
struts-logic | http://jakarta.apache.org/struts/tags-logic | http://struts.apache.org/tags-logic |
struts-nested | http://jakarta.apache.org/struts/tags-nested | http://struts.apache.org/tags-nested |
struts-template | http://jakarta.apache.org/struts/tags-template | 不再包括,被Tiles代替 |
struts-tiles | http://jakarta.apache.org/struts/tags-tiles | http://struts.apache.org/tags-tiles |
struts-bean-el | http://jakarta.apache.org/struts/tags-bean-el | http://struts.apache.org/tags-bean-el |
struts-html-el | http://jakarta.apache.org/struts/tags-html-el | http://struts.apache.org/tags-html-el |
struts-logic-el | http://jakarta.apache.org/struts/tags-logic-el | http://struts.apache.org/tags-logic-el |
相关文章推荐
- JSP学习笔记之三——关于servlet配置web.xml出现的问题
- web.xml中taglib标签报错问题解决方案
- 关于 web.xml 3.1 以及 jsp2.0下使用fmt标签 异常的问题
- jsp servlet的web.xml的配置中碰到的诡异问题
- 关于jsp web项目,jsp页面与servlet数据不同步的解决办法(报错404、405等)即访问.jsp和访问web.xml中注册的/servlet/的区别
- 解决servlet在web.xml中的路径跳转问题
- jsp tomcat apache web.xml编译错误问题解决
- web.xml文件中的jsp-config标签详解 --可用于解决jsp、html乱码问题
- 【WEB】jsp向servlet传参中文乱码问题解决
- jsp提交到Servlet报404错误问题解决(webroot下子目录)
- web.xml中taglib标签报错问题解决方案
- Web.xml配置<taglib>标签报错问题(cvc-complex-type.2.4.a: Invalid content was found starting with element 'tag
- 解决Get和Post请求中中文乱码问题 (2013-01-26 23:59:39)转载▼ 标签: javaee it 分类: JavaEE 对于Post请求,只需在Servlet或者jsp中写入如下
- 解决新版web.xml中配置 taglib的问题
- jsp提交到Servlet报404错误问题解决(webroot下子目录)
- Java EE开发中Eclipse ee Servlet不能自动在web.xml里写入的问题
- jsp页面写入中文到mysql时出现乱码 问题解决
- IntelliJ IDEA 2017.3创建Struts2项目,解决无自动生成web.xml问题
- 不同版本(2.3,2.4,2.5,3.0)的Servlet web.xml 头信息
- jsp/servlet中链接中出现中文乱码问题的解决办法及个人见解