【发布时间】:2015-10-12 14:58:44
【问题描述】:
我已经摔跤好几天了。我有一个简单的教程项目,每当我将以下指令添加到我的简单 JSP 中时,页面都无法加载:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Tomcat 的错误
Oct 12, 2015 3:23:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [offers] in context with path [] threw exception [The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application] with root cause
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or thejar files deployed with this application
我的文件:
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>andy</groupId>
<artifactId>pizza</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
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/java
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>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<description>Spring Database</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/spring</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
home.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title></title>
</head>
<body>
Hello sir!
</body>
</html>
IntelliJ 中的项目结构
交付的页面:
任何帮助将不胜感激!
【问题讨论】:
-
像这样
jstl 更改 pom.xml 中的组 id 并尝试运行。 -
谢谢,但遗憾的是这似乎对结果没有任何影响。
-
stackoverflow.com/questions/5148180/how-to-add-jstl-to-maven 看看这个。它可能会有所帮助。
-
我已经编辑了我的答案。也试试其他答案。
-
你解决了吗?我在 intellij 15 上遇到了完全相同的问题
标签: spring jsp maven intellij-idea jstl