首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能在Intellij IDEA中用uri解析标签库

不能在Intellij IDEA中用uri解析标签库
EN

Stack Overflow用户
提问于 2017-05-18 06:01:41
回答 1查看 4.6K关注 0票数 1

通过查看教程系列JSP, Servlets and JDBC for Beginners: Build a Database App on 乌德米,由Chad Darby完成,并在BalusC答案的帮助下,我用Intellij IDEA编写了以下代码

代码语言:javascript
复制
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--To use JSTL core tags we need to import the following URL with prefix--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Title</title>
</head>

<%
    // need to define a sample array
    String cities[]={"City1","City2","City3","City4"};
    // to use JSTL tags they have a to be a part of an attribute, either in the scope of the pageContext, session or application
    pageContext.setAttribute("myCities",cities);

%>
<body>
<%-- for printing them in for each loop--%>
<c:forEach var="cityName" items="${myCities}" >
    <%-- here we are using JSP expression language as ${...}}--%>
    ${cityName} <br/>
</c:forEach>

</body>
</html>

并按照教程作者的建议(注意:教程是在JSTL上做的)和BalusC答案,在WEB-INF/lib下添加Eclipse IDE库。代码工作正常,但是IDEA编辑器给了我

无法用uri http://java.sun.com/jsp/jstl/core解析标签库

无法解析符号c:forEach

这些线条都是红色的,如图中所示。

为什么会发生这种事?在IDEA中还有其他地方可以添加这些库吗?提前感谢

EN

回答 1

Stack Overflow用户

发布于 2017-10-11 20:17:42

在使用基于spring的项目时,我收到了类似的消息。我通过在pom.xml中添加以下依赖项来解决这个问题

代码语言:javascript
复制
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

下一步,打开终端,然后执行maven干净安装。

代码语言:javascript
复制
mvn -U clean install
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44039706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档