问题
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