My web.xml doesn't know the taglib tag

I want to use html tags in my jsp, so I need to add the lib tag to web.xml when I add these lines to web.xml:

<taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

      

he doesn't know the taglib tag

+3


source to share


3 answers


Tags

<taglib>

must be inside the tag <jsp-config>

.

But using Struts2

, you absolutely don't need the struts-html

taglib, it's from Struts 1, which is older and completely different.



Just browse through the features Struts2

and you will find that you no longer need to use html tags, thankfully.

+3


source


In newer versions of JSP / Servlet containers, the taglib entry is not required web.xml

as the containers will automatically find it.

You only need a directive <%@ taglib %>

in your JSP page to use .tld files:



<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>

      

+5


source


There are three ways to customize a tag library.

  • Manual throw setting web.xml

    :
    Make sure the tld files are copied to the folder WEB-INF

    , set them web.xml

    as below, use the taglib attribitete attribute in the taglib directive like <%@ taglib uri="mytagliburi" prefix="ww" %>

    .

...

<taglib>
         <taglib-uri>mytagliburi</taglib-uri>
         <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib> 

      

  1. Manual configuration with directive onlytaglib

    . Make sure the tld files are copied to the folder WEB-INF

    and configure directly in the taglib directory as <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="ww" %>

    .
  2. Automatic setting . This is an easy way and is used in Struts version 1.2, just include it struts-taglib.jar

    in the project classpath

    or copy it to a folder WEB-INF/lib

    . All details are tld

    defined inside the folder struts-taglib.jar\META-INF\tld

    . During deployment, all tlds will be deployed automatically. However, we can only access it using the name pre-fixed uri

    . In this method, we cannot change the name taglib uri

    .
0


source







All Articles