在Intellij IDEA中无法使用uri解析taglib

时间:2017-05-18 06:01:42

标签: java jsp intellij-idea jstl taglib

通过查看JSP, Servlets and JDBC for Beginners: Build a Database App上由Chad Darby完成的教程系列Intellij IDEA并在Udemy的帮助下,我在<%@ 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

并按照本教程作者(注意:教程已在WEB-INF/lib完成)和Eclipse IDE回答的建议,在BalusC下添加IDEA个库。代码工作正常,但IDEA编辑给我

  

无法使用uri BalusC answer

解析taglib

  

无法解析符号&#39; c:forEach&#39;

并且这些线条呈红色,如图http://java.sun.com/jsp/jstl/core

所示

为什么会这样?在tableView.scrollToColumn(anyColumn); 中是否还有其他地方可以添加这些库?提前致谢

1 个答案:

答案 0 :(得分:0)

在使用基于Spring的项目时,我收到了类似的消息。我通过在pom.xml

中添加以下依赖项来解决它
        <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 clean install

mvn -U clean install