taglib标签在web.xml中报错处理方法
2010-03-30 11:52
176 查看
struts2开发中遇到这个问题,web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="person" 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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>person</display-name>
<!-- Include this if you are using Hibernate -->
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Filters -->
<filter>
<filter-name>action2-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
</filter>
<filter>
<filter-name>action2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>action2-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>
WEB-INF/sitemesh-decorator.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
其中的taglib标签加入后,eclipse会报cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. ... 错误。
解决方法是在taglib外面加个jsp-config标签:
<jsp-config>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>
WEB-INF/sitemesh-decorator.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
</jsp-config>
<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。
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="person" 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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>person</display-name>
<!-- Include this if you are using Hibernate -->
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Filters -->
<filter>
<filter-name>action2-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
</filter>
<filter>
<filter-name>action2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>action2-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>
WEB-INF/sitemesh-decorator.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
其中的taglib标签加入后,eclipse会报cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. ... 错误。
解决方法是在taglib外面加个jsp-config标签:
<jsp-config>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>
WEB-INF/sitemesh-decorator.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
</jsp-config>
<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。
相关文章推荐
- <taglib>标签在web.xml文件中报错解决方法
- web.xml不认taglib标签的解决方法
- web.xml不认taglib标签的解决方法
- taglib标签在web.xml文件中报错的解决办法
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml... 处理方法
- [教程]自定义JSP中的Taglib标签之六Taglib中常用的属性值与tld常用标签简介与web.xml设置自定义标签的uri
- web工程中web.xml添加taglib标签报错的解决办法
- web.xml中无法识别taglib标签
- web.xml中taglib标签报错问题解决方案
- JSP 2.0 web.xml不再直接支持<taglib>标签配置
- Taglib中常用的属性值与tld常用标签简介与web.xml设置自定义标签的uri
- Selenium2(Webdriver)+Python处理浏览器多标签方法二则
- Tomcat6和7版本对web.xml中taglib标签的配置差异
- web.xml配置taglib标签出错
- 【Java.Web】JSP —— 标签库taglib —— 第三方标签库 —— JSTL XML
- web.xml 不认 taglib 的解决方法
- web.xml中不识别标签的解决方法
- JSP 2.0 web.xml不再直接支持<taglib>标签配置
- J2EE WEB项目web.xml标签使用方法