Adding JSTL to jsp (Tomcat 8) [duplicate]

99封情书 提交于 2019-12-22 05:17:25

问题


I want to use the JSTL library in my jsp's. Now I followed a tutorial and it told me to add this line to the jsp page:

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

It gives me the error cannot resolve taglib with uri and then the URL.

I'm running tomcat 8. My web.xml is like this:

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Does someone know how to fix this?


回答1:


You need to add jar for the jstl library in your classpath. If you are using maven, then add this dependency.

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

Add this to your pom.xml.




回答2:


To resolve this issue, you would need to do the following:

  • The jstl.jar should be in your classpath. (Download jar / pom)
  • Make sure you have the following taglib directive at the top of your jsp:

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


来源:https://stackoverflow.com/questions/28026991/adding-jstl-to-jsp-tomcat-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!