tomcat8.0 jsp 中配置 jstl 后启动报错

1. maven pom 添加依赖
   <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>jstl</artifactId>
          <version>1.2</version>
      </dependency>

检查依赖正常

clipboard.png

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

添加指令的时候ide没有抛错并且会自动提示。

3. 但是在启动服务的抛出异常
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jsp] in context with path [] threw exception [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] with root cause
 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
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:80)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

查询过解决办法

  1. 将 apache 的 standard.jar 包导入
  2. 将 jstl.jar 和 standard.jar copy 到 web-inf/lib 目录下
  3. 还有说 jstl1.2 不需要standard.jar
  4. 还有确定 taglib 的 uri 是 http://java.sun.com/jsp/jstl/...

上面的四种方法我都试过,并且都失败了。
有哪位同学或前辈知道原理的麻烦解释下,或者告知一下解决办法。不胜感激。。。
我的 ide 是 ideaJ

阅读 4.7k
1 个回答

jstl相关的依赖弄错了,是这个:

<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>${jstl.version}</version>
</dependency>

再有就是jstl1.2版本之后是不需要standard.jar的...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏