我使用Intellij Idea 2016.2.2和Tomcat Server 8.0.27。我在jsp文件的顶部包含标签库,如下所示:
<%@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->Libraries->'+'From Java->JSTL jar位置。在此之后,jar出现在外部库下。但是它不工作。
2)然后我发现这个链接在堆栈溢出https://stackoverflow.com/a/32444393/6189499
我遵循相同的程序,但不起作用。如何解决这个问题?
-
在web/web -inf下创建一个lib目录。
-
下载jstl 1.2 jarhttps://mvnrepository.com/artifact/jstl/jstl/1.2
- 进入Intellij -> Project Structure -> Artifacts -> Add lib目录内容 重建项目并重启Tomcat。
添加:javax.servlet.jsp.jstl-1.2.1.jar
和javax.servlet.jsp.jstl.jar
重新启动Tomcat并重新部署项目。