无法使用Intellij Idea和Tomcat解析Taglib

时间:2016-09-10 01:45:36

标签: intellij-idea jstl tomcat8

我正在使用Intellij Idea 2016.2.2和Tomcat Server 8.0.27。我在顶部的jsp文件中包含了taglib,如下所示:

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

当我在Tomcat中解复并运行代码后,会生成错误。

HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

type Exception report

message The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:277)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:243)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:124)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:416)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:474)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1430)
    org.apache.jasper.compiler.Parser.parse(Parser.java:139)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    com.himal.jdbcservlet.controller.CourseController.doPost(CourseController.java:46)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52

然后,我读过我读过的 https://www.jetbrains.com/help/idea/2016.2/configuring-module-dependencies-and-libraries.html

1)我通过以下步骤添加。 ProjectStructure-&gt; Libraries-&gt;&#39; +&#39;来自Java-&gt; JSTL jar位置。在此之后,该jar出现在外部库下。但它没有用。

2)然后我在堆栈溢出https://stackoverflow.com/a/32444393/6189499

中发现了这个链接

我遵循了相同的程序,但没有奏效。 我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

  1. 在web / WEB-inf下创建一个lib Directorory。

  2. 从中下载jstl 1.2 jar https://mvnrepository.com/artifact/jstl/jstl/1.2

  3. 转到Intellij - &gt;项目结构 - &gt;文物 - &gt;添加lib目录内容。
  4. 重建项目并重新启动Tomcat。

答案 1 :(得分:0)

添加:
javax.servlet.jsp.jstl-1.2.1.jar
javax.servlet.jsp.jstl.jar
重新启动Tomcat并重新部署项目。