使用Web片段时,无效的tagdir属性 [英] Invalid tagdir attribute while web-fragment is used

查看:186
本文介绍了使用Web片段时,无效的tagdir属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Web片段功能将我的JSP和标签维护在一个jar中,并且使用这种方法,我的JSP页面无法找到tagdir,并导致此标签库的tagdir属性值无效."

I am using web-fragment feature to maintain my JSPs and tags in a jar, and using this approach, my JSP pages are unable to find the tagdir, and cause "The value of the tagdir attribute for this tag library is invalid."

这是我罐子里的结构.

META-INF
-资源
   -WEB-INF
       -标签
               "" mytag.tag
   -mypage.jsp
-web-fragment.xml

META-INF
-- resources
    -- WEB-INF
        -- tags
            -- mytag.tag
    -- mypage.jsp
-- web-fragment.xml

在mypage.jsp中,我指定taglib如下:

In mypage.jsp, I specify the taglib as following:

我得到了这些错误:
mypage.jsp:7:4:taglib指令必须指定"uri"或"tagdir"属性.

And I got these errors:
mypage.jsp:7:4: The taglib directive must specify either the "uri" or "tagdir" attribute.

mypage.jsp:7:33:此标记库的tagdir属性值无效.

mypage.jsp:7:33: The value of the tagdir attribute for this tag library is invalid.

在这种方法下,似乎找不到tagdir.我在战争中使用web.xml尝试了相同的结构,并且能够找到标签.因此,我想知道是否有任何办法可以将类似的解决方案与Web碎片方法一起使用.

It seems like under this approach, it cannot find the tagdir. I tried the same structure in my war with web.xml, and it was able to find the tags. So I wonder if there is any way I can use the similar solution with web-fragment approach.

推荐答案

您不需要在Web片段项目中使用WEB-INF.请改用以下结构:

You don't need WEB-INF in the web-fragment project. Use this structure instead:

网络片段项目:

META-INF/
-- resources/
   -- tags/
      -- mytag.tag
   -- mypage.jsp
-- web-fragment.xml

resources目录中的所有内容现在都可以用来引用项目,就像它们是部署在WEB-INF 内部.

Everything inside the resources directory will now be available to referencing projects as if they were deployed inside WEB-INF.

网络项目:

WEB-INF/
-- tags/
   -- othertag.tag
   -- (mytag.tag)
-- otherpage.jsp
-- (mypage.jsp)

因此要在 web 项目中引用mytag.tag:

<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
...
<my:mytag ... />

至于您看到的错误,我不知道您尝试了什么,但是这是您的处理方式:

As for the errors you are seeing, I don't know what you tried, but here's how you'd do it:

对于.tag,您必须指定 tagdir 并将其设置到标签的文件夹中:

for a .tag you must specify tagdir and set it to the tag's folder:

<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>

对于.tld,您必须指定 uri ,并将其设置为 tld的URI :

for a .tld you must specify uri and set it to the tld's URI:

<%@ taglib prefix="mytld" uri="http://example.com/tld/my" %>

这篇关于使用Web片段时,无效的tagdir属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆