在Intellij IDEA中无法使用uri解析taglib [英] Cannot resolve taglib with uri in Intellij IDEA

查看:1196
本文介绍了在Intellij IDEA中无法使用uri解析taglib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



为什么会这样?是否还有其他地方可以在 IDEA 中添加这些库?在此先感谢

解决方案

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

 < dependency> 
< groupId> org.apache.tomcat.embed< / groupId>
< artifactId> tomcat-embed-jasper< / artifactId>
< scope>提供< / 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 


By looking at the tutorial series JSP, Servlets and JDBC for Beginners: Build a Database App on Udemy done by Chad Darby and with the help of BalusC answer I wrote the following code in Intellij IDEA

<%@ 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>

and add the JSTL libs under WEB-INF/lib as suggested by both the author of the tutorial (note: tutorial is done on Eclipse IDE) and BalusC answer. The code works fine, but IDEA editor give me

cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core

and

cannot resolve symbol 'c:forEach'

and those lines are in red color as seen in the image

Why is this happening?. Is there any other place to add those libraries in IDEA? Thanks in advance

解决方案

I got similar kind of message while working with spring based project. I resolved it by adding following dependencies inside 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>

next open terminal and then do maven clean install

mvn -U clean install

这篇关于在Intellij IDEA中无法使用uri解析taglib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆