JSTL in IntelliJ gives errors in JSP

2019-02-06 00:59发布

I'm playing with Google App Engine in IntelliJ. I'm trying to use JSTL tags in my JSPs. I've tried two different URIs I found on the internet, and both of them give me errors:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

and

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

It reds out the URL and says it cannot resolve taglib. I've tried dropping different parts of the URL to see if Ctrl-Space gives me any autocomplete love, but no luck.

Any ideas what I need to do to make this work?

3条回答
forever°为你锁心
2楼-- · 2019-02-06 01:24

Add something like this to your pom.xml under the <dependencies> node (you are using maven, right?):

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>2.5</version>
</dependency>

For gradle and other build systems see https://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5

Also, make sure you pick a suitable version for your project. To see all available versions check here.

查看更多
霸刀☆藐视天下
3楼-- · 2019-02-06 01:37

Make sure that JSTL library jars are added to the module dependencies.

查看更多
劳资没心,怎么记你
4楼-- · 2019-02-06 01:46

In my case, I had to download the .jar from apache (https://tomcat.apache.org/taglibs/standard/) and add to my project dependencies.

File > Project Structure > Modules > Dependencies
查看更多
登录 后发表回答