java 将 JSTL 添加到 jsp (Tomcat 8)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28026991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding JSTL to jsp (Tomcat 8)
提问by user1007522
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:
我想在我的 jsp 中使用 JSTL 库。现在我遵循了一个教程,它告诉我将此行添加到 jsp 页面:
<%@ 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.
它给了我错误无法用 uri 和 URL 解析 taglib。
I'm running tomcat 8. My web.xml is like this:
我正在运行 tomcat 8。我的 web.xml 是这样的:
<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?
有人知道如何解决这个问题吗?
采纳答案by z21
You need to add jar for the jstl
library in your classpath. If you are using maven, then add this dependency.
您需要jstl
在类路径中为库添加 jar 。如果您使用的是 maven,则添加此依赖项。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Add this to your pom.xml.
将此添加到您的 pom.xml。