无法运行包含jstl标记的jsp页面。说..无法读取TLD“META-INF / c.tld”

时间:2012-03-22 09:02:02

标签: jsp java-ee maven jstl

我正在开发一个我希望使用jstl的maven项目。最初,jsp文件显示异常,如classnotfound,无法找到org.apache.taglib.standard .....

然后我搜索并在web-inf / tags / template文件夹中添加了c.tld文件,并在web.xml中添加了路径,我尝试将其保存到web-inf / tags中但是发生了同样的异常 我还在web-inf / lib文件夹中添加了jstl.jar和standard.jar

我还在pom.xml上添加了依赖项

<dependency>
            <groupId>com.sap.jpaas.service.securestore</groupId>
            <artifactId>
                com.sap.jpaas.service.securestore.feature
            </artifactId>
            <version>0.1.2</version>
        </dependency>
        <dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>jstl</artifactId>
           <version>1.1.2</version>
        </dependency>

        <dependency>   
          <groupId>taglibs</groupId> 
          <artifactId>standard</artifactId> 
          <version>1.1.2</version> 
        </dependency>
        <dependency>   
          <groupId>javax.servlet.jsp</groupId> 
          <artifactId>jsp-api</artifactId> 
          <version>2.0</version>
          <scope>provided</scope>
</dependency>

servlet的版本是2.5

毕竟这不起作用...... :( 给出以下错误..

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.NewFile_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:177)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Unknown Source)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

根本原因

java.lang.ClassNotFoundException: org.apache.jsp.NewFile_jsp
    java.net.URLClassLoader$1.run(Unknown Source)
    java.security.AccessController.doPrivileged(Native Method)
    java.net.URLClassLoader.findClass(Unknown Source)
    org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)
    org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
    java.security.AccessController.doPrivileged(Native Method)
    javax.security.auth.Subject.doAsPrivileged(Unknown Source)
    org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
    org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

刷新后会出现以下错误

org.apache.jasper.JasperException: /NewFile.jsp (line: 3, column: 65) Unable to read TLD "META-INF/c.tld" from JAR file "file:/C:/Users/i069130/eclipse/Jpaas-Workspace/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/com.sap.javax.servlet.jsp.jstl_1.2.0.BUILD-20100618.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:182)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Unknown Source)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

我正在使用maven项目,eclipse indigo和使用derby db的sap netweaver neo服务器

1 个答案:

答案 0 :(得分:0)

  

然后我搜索并在web-inf / tags / template文件夹中添加了c.tld文件

这是不对的。去掉它。

  

并在web.xml中添加了路径

这也不对。删除它。

  

我尝试将其保存到web-inf / tags

这也不对。删除它。

安装JSTL应该是在/WEB-INF/lib文件夹中使用JSTL API和impl JAR文件。没有别的事情需要做。您需要确保Maven配置正在执行此操作。到目前为止,它看起来对JSTL 1.1来说没问题,但是你的JSP依赖关系对于Servlet 2.5是错误的。 JSP版本应该是2.1。

<dependency>   
     <groupId>javax.servlet.jsp</groupId> 
     <artifactId>jsp-api</artifactId> 
     <version>2.1</version>
     <scope>provided</scope>
</dependency>

当您想要使用JSTL时,不要忘记在JSP顶部声明正确的taglib URI:

<%@taglib prefix="c" uri="http://java.sun.som/jsp/jstl/core" %>

另见: