A. Andevski
A. Andevski

Reputation: 437

Can't get JSTL to work with Spring MVC

I can't seem to get JSTL working with my current installation. I recently started fiddling around with Spring MVC, learning as I'm trying stuff. It was great until I got to using JSTL, which I can't seem to get it right.

The error I get is

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.jsp.HelloWorld_jsp

My HelloWorld.jsp file:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Posts</title>
</head>
<body>
<c:foreach var="post" items="${listPosts}" varStatus="status">
    ${status.index + 1} ${post.title}<br />
</c:foreach>
</body>
</html>

And in case you need them, my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>HelloWorld</artifactId>
    <version>1.0-SNAPSHOT</version>

</project>

And web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

I have the CLASSPATH environment variable set up properly (to the lib folder of tomcat) and I tried putting jstl-1.2.jar in the WEB-INF/lib folder as well as trying to declare dependencies several times in pom.xml (doing things I googled, not sure how correct they are). Nothing worked so far.

Upvotes: 0

Views: 1532

Answers (1)

paulsm4
paulsm4

Reputation: 121669

It's very likely the problem is missing dependencies in your pom.xml.

SUGGESTIONS:

Please post back what you find!

Upvotes: 0

Related Questions