绝对 uri:http://java.sun.com/jsp/jstl/core 无法在 web.xml 或使用此应用程序部署的 jar 文件中解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28474448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this app
提问by
I have problem with this error in spring mvc
我有这个错误的问题 spring mvc
I saw similar issues, but a wonderful thing is that i have not any lib
folder under WEB-INF
!
我看到了类似的问题,但很棒的是我没有任何lib
文件夹WEB-INF
!
I am using jdk 1.7
and netbeans7
and maven
.
我使用的jdk 1.7
和netbeans7
和maven
。
Here is my project structure:
这是我的项目结构:
This is pom.xml
:
这是pom.xml
:
<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>com.sajjad</groupId>
<artifactId>OnlineBookStore2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>OnlineBookStore2</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>org-apache-commons-logging</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>cglib-2.2</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-aop-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-aspects-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-beans-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-build-src-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-context-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-context-support-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-core-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-expression-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-framework-bom-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-instrument-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-instrument-tomcat-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-jdbc-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-jms-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-messaging-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-orm-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-oxm-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-test-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-tx-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-web-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-webmvc-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-webmvc-portlet-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>spring-websocket-4.0.1.RELEASE</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>hibernate-jpa-2.1-api-1.0.0.Final</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
</project>
And this is my web.xml
:
这是我的web.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<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>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
And this is my dispatcher-servlet.xml
:
这是我的dispatcher-servlet.xml
:
<?xml version='1.0' encoding='UTF-8' ?>
<beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<context:component-scan base-package="sajjad.htlo"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/pics/" />
<mvc:default-servlet-handler/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="viewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
My controller class:
我的控制器类:
@Controller
public class IndexController {
@RequestMapping(value = "/index.html")
public ModelAndView indexPage() {
return new ModelAndView("index");
}
}
My view jsp
file:
我的视图jsp
文件:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
</head>
<body>
this is index page
<img src="resources/pics/t3.jpg" />
</body>
</html>
When i try : http://localhost:8080/OnlineBookStore2/index.html
This error happens:
当我尝试时:http://localhost:8080/OnlineBookStore2/index.html
发生此错误:
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
org.apache.jasper.JasperException: 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
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:445)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:117)
...
I am going to access image from jsp
file.
我将从jsp
文件中访问图像。
UPDATE
更新
I created lib
folder under WEB-INF
and put jstl-1.2.jar
on it, as you can see in the picture:
我在lib
下面创建了文件夹WEB-INF
并将其放在jstl-1.2.jar
上面,如图所示:
But i have the same problem yet.
但我还有同样的问题。
采纳答案by Liam de Haas
回答by justjava
You need to add the jstl tag library to the WEB-INF/lib folder. if you don't have one you make the lib folder. Download JAR from https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
您需要将jstl 标记库添加到WEB-INF/lib 文件夹中。如果您没有,则创建 lib 文件夹。从https://mvnrepository.com/artifact/javax.servlet/jstl/1.2下载 JAR
Adding Maven Dependency Does Not Work.
添加 Maven 依赖项不起作用。
回答by Sanjay
Please Add this dependency im pom.xml.
请添加此依赖项 im pom.xml。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
回答by Neil McGuigan
In your Maven POM, in the <dependencies>
section, add
在您的 Maven POM<dependencies>
部分中,添加
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
回答by mfruizs2
In my case, I had got the library on pom, but with scope as provided
.
就我而言,我在 pom 上获得了库,但范围为provided
.
In that case, we need to add the library on your server, maybe /lib
or in your proyect WEB-INF/lib
在这种情况下,我们需要在您的服务器上/lib
或在您的项目中添加该库WEB-INF/lib
On the other hand, we can remove that scope.
另一方面,我们可以删除该范围。
回答by Waldo Alvarez
Very simple to fix. In Netbeans left click your project, click properties, choose libraries and there click "add library". There you choose "JSTL 1.2.1" and click the new "add library" in the dialog.
修复起来非常简单。在 Netbeans 中左键单击您的项目,单击属性,选择库,然后单击“添加库”。在那里您选择“JSTL 1.2.1”并在对话框中单击新的“添加库”。