java - Weblogic 中的 JSTL 支持

标签 java jakarta-ee weblogic jstl web.xml

我正在尝试使用 Weblogic 开始使用 Java EE,但我无法使 JSTL 标记工作,在最简单的代码中,我在部署我的应用程序时遇到以下错误:

index.jsp:1:4: No tag library could be found with this URI. Possible causes could be that the URI is incorrect, or that there were errors during parsing of the .tld file. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

^----^ index.jsp:1:4: No tag library could be found with this URI. Possible causes could be that the URI is incorrect, or that there were errors during parsing of the .tld file. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

^----^ index.jsp:2:4: No tag library could be found with this URI. Possible causes could be that the URI is incorrect, or that there were errors during parsing of the .tld file. <%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>

^----^ index.jsp:2:4: No tag library could be found with this URI. Possible causes could be that the URI is incorrect, or that there were errors during parsing of the .tld file. <%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>

我从这个网站下载了 taglib 文件:http://archive.apache.org/dist/jakarta/taglibs/standard/ 并将两个 jar (standard.jar 和 jSTL.jar)放在我的 WEB-INF 目录下。我还将 arcihve 中的所有 tld 文件放在那里。 在我尝试在我的 web.xml 文件中引用它们并在验证后我收到以下错误:

XML validation started. Checking file:/C:/Users/Brodyaga/Documents/NetBeansProjects/Eshop1/web/WEB-INF/web.xml... Referenced entity at "nbres:/org/netbeans/modules/j2ee/ddloaders/catalog/resources/XMLSchema.dtd". Referenced entity at "nbres:/org/netbeans/modules/j2ee/ddloaders/catalog/resources/datatypes.dtd". cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":distributable, "http://java.sun.com/xml/ns/javaee":context-param, "http://java.sun.com/xml/ns/javaee":filter, "http://java.sun.com/xml/ns/javaee":filter-mapping, "http://java.sun.com/xml/ns/javaee":listener, "http://java.sun.com/xml/ns/javaee":servlet, "http://java.sun.com/xml/ns/javaee":servlet-mapping, "http://java.sun.com/xml/ns/javaee":session-config, "http://java.sun.com/xml/ns/javaee":mime-mapping, "http://java.sun.com/xml/ns/javaee":welcome-file-list, "http://java.sun.com/xml/ns/javaee":error-page, "http://java.sun.com/xml/ns/javaee":jsp-config, "http://java.sun.com/xml/ns/javaee":security-constraint, "http://java.sun.com/xml/ns/javaee":login-config, "http://java.sun.com/xml/ns/javaee":security-role, "http://java.sun.com/xml/ns/javaee":env-entry, "http://java.sun.com/xml/ns/javaee":ejb-ref, "http://java.sun.com/xml/ns/javaee":ejb-local-ref, "http://java.sun.com/xml/ns/javaee":service-ref, "http://java.sun.com/xml/ns/javaee":resource-ref, "http://java.sun.com/xml/ns/javaee":resource-env-ref, "http://java.sun.com/xml/ns/javaee":message-destination-ref, "http://java.sun.com/xml/ns/javaee":persistence-context-ref, "http://java.sun.com/xml/ns/javaee":persistence-unit-ref, "http://java.sun.com/xml/ns/javaee":post-construct, "http://java.sun.com/xml/ns/javaee":pre-destroy, "http://java.sun.com/xml/ns/javaee":message-destination, "http://java.sun.com/xml/ns/javaee":locale-encoding-mapping-list}' is expected. [12] XML validation finished.

我的 web.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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-app_2_5.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
        <taglib-location>/WEB-INF/fmt.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
        <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
        <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
        <taglib-location>/WEB-INF/sql.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
        <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
        <taglib-location>/WEB-INF/x.tld</taglib-location>
    </taglib>

    <taglib>
        <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
        <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
    </taglib>
</web-app>

我相信 web.xml 开头指定的 xml 模式不允许使用 taglib 标签,但我不知道应该使用什么模式。

我真的很感激一些将 jSTL 支持添加到 weblogic 的分步教程。提前致谢。

更新 从 web.xml 中删除那些 最终会出现如下错误:

index.jsp:18:14: The tag handler class was not found "org.apache.taglibs.standard.tag.rt.core.ForEachTag".

根据 c.tld 文件的内容,很明显 weblogic 理解 forEach 对应于 org.apache.taglibs.standard.tag.rt.core.ForEachTag,但无法找到该类。但是我可以在 standard.jar 中手动找到这个类。

最佳答案

您必须将 jSTL.jar 和 standard.jar 都包含在 WEB-INF/lib 文件夹中,而不是在 WEB-INF 文件夹中。我想这会解决这个问题。

关于java - Weblogic 中的 JSTL 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5417442/

相关文章:

java - 如何在不立即订阅的情况下调用RxJava Observable?

java - 如何在java中减小图像文件的大小

Java用(管道) "... -f nut - | ffmpeg -i - ..."执行ffmpeg命令只是挂起

jakarta-ee - TomEE和数据源:用户缺少特权或找不到对象

jakarta-ee - 从不同的服务器远程访问 EJB

javamail isSSL false 即使我在发送邮件时将 tls 设置为 True

java - 如何在运行时获取weblogic托管服务器监听端口?

java - Tomcat下解析XML文档时weblogic的DOMFactoryProperties出现NullPointerException

java - Tomcat 有时无法通过 eclipse 在 ubuntu14.04 中启动

java - 将 json 对象中的日期发送到 Restful ws