Error Handling Method for taglib labels in Web. xml

Source: Internet
Author: User
Tags tld

This problem occurs during struts2 development. The web. XML is as follows:

<? 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>
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>

After the taglib label is added, eclipse will report the cvc-complex-type.2.4.a: Invalid Content was found starting with element 'taglib'... error.

The solution is to add a JSP-config tag outside taglib:

<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>
WEB-INF/sitemesh-page.tld </taglib-location>
</Taglib>
</JSP-config>

<JSP-config> detailed description of tag usage
<JSP-config> includes two sub-elements: <taglib> and <JSP-property-group>.

The <taglib> element already exists in JSP 1.2, and <JSP-property-group> is a new element in JSP 2.0.
The <JSP-property-group> elements mainly have eight child elements:

1. <description>: Set description;
2. <display-Name>: Set the name;
3. <URL-pattern>: Set the range affected by the value, for example,/CH2 or/*. jsp;
4. <El-ignored>: if it is true, El syntax is not supported;
5. <Scripting-invalid>: if it is true, the <% scripting %> syntax is not supported;
6. <page-encoding>: sets the JSP page encoding;
7. <include-prelude>: Set the JSP page header with the extension. jspf;
8. <include-coda>: set the end of the JSP page with the extension. jspf.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.