【发布时间】:2016-01-27 10:23:50
【问题描述】:
当我尝试为我的 web.xml 使用 XML 架构而不是弃用的 DOCTYPE 声明时,我得到了以下 JasperException:
HTTP Status 500 - 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
如果我使用这个 web.xml,应用程序编译:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
但是,如果我使用这个 web.xml,我会得到 JasperException:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>CourseManagementJDBC</display-name>\
</web-app>
知道为什么只有弃用的格式可以工作吗?
注意:这是一个Maven项目,已经正确声明了JSTL依赖,以及JSP中的标签库:
pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
JSP:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
他们都是正确的;什么给了?
【问题讨论】:
-
访问jsp页面时是编译时还是运行时报错?
-
在编译时。它成功编译的唯一方法是在 web.xml 中使用旧的、已弃用的 DOCTYPE 声明。 xml。我只是不知道为什么。