Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 标记文件目录/WEB-INF/functions.tld不以“开始”/WEB-INF/tags";_Java_Jsp Tags - Fatal编程技术网

Java 标记文件目录/WEB-INF/functions.tld不以“开始”/WEB-INF/tags";

Java 标记文件目录/WEB-INF/functions.tld不以“开始”/WEB-INF/tags";,java,jsp-tags,Java,Jsp Tags,我有一个有趣的问题。。。我正在尝试将JSP标记添加到我的应用程序中。我在/WEB-INF/tags/中存储了functions.tld,但我收到了错误消息非法的tld路径/WEB-INF/tags/functions.tld,不能以“/WEB-INF/tags”开头/WEB-INF/,然后我得到了标记文件目录/WEB-INF/functions.tld不能以“/WEB-INF/tags”开头。那么我应该把它放在哪里 TLD文件 <?xml version="1.0" encoding="U

我有一个有趣的问题。。。我正在尝试将JSP标记添加到我的应用程序中。我在
/WEB-INF/tags/
中存储了
functions.tld
,但我收到了错误消息
非法的tld路径/WEB-INF/tags/functions.tld,不能以“/WEB-INF/tags”开头
/WEB-INF/
,然后我得到了
标记文件目录/WEB-INF/functions.tld不能以“/WEB-INF/tags”开头
。那么我应该把它放在哪里

TLD文件

<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
        version="2.1">

    <tlib-version>1.0</tlib-version>
    <short-name>my</short-name>

    <!-- Invoke 'Generate' action to add tags or functions -->
    <function>
        <name>urlencode</name>
        <function-class>library.StringUtils</function-class>
        <function-signature>java.lang.String urlencode(java.lang.String)</function-signature>
    </function>

</taglib>
在/tag/文件夹中时出错

  Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
org.apache.jasper.JasperException: PWC6336: Illegal TLD path /WEB-INF/tags/functions.tld, must not start with "/WEB-INF/tags"
    at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:573)
    at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:566)
    at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:354)
    at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:242)
    at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5713)
    at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:623)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5609)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:540)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:900)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2044)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1690)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
  Startup of context  failed due to previous errors]]

这是一个简单的误解。稍微考虑一下,使用属性tagdir引用单个标记文件没有多大意义。正确的方法是将TLD文件放入WEB-INF目录,然后使用

<%@ taglib prefix="f" uri="/WEB-INF/functions.tld" %>

换句话说:将tagdir替换为uri


这和答案解释了区别。

当您使用uri属性时会发生什么,
?我解释为什么我会问这个问题可能会有所帮助:我发现奇怪的是,您会使用名为tagdir的属性来引用标记文件,从而查找如何定义自定义taglib,这导致了一个使用uri属性的示例。@Gimby它没有错误:)。正在检查它是否正常…@Gimby是的,正常。你想把它写在一个答案里,这样我就可以把它标记为正确的吗?
  Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
org.apache.jasper.JasperException: PWC6336: Illegal TLD path /WEB-INF/tags/functions.tld, must not start with "/WEB-INF/tags"
    at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:573)
    at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:566)
    at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:354)
    at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:242)
    at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5713)
    at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:623)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5609)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:540)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:900)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2044)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1690)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
  Startup of context  failed due to previous errors]]
<%@ taglib prefix="f" uri="/WEB-INF/functions.tld" %>