绝对uri:http://java.sun.com/jsp/jstl/core无法解析

发布于 2024-11-01 13:51:07 字数 8161 浏览 0 评论 0原文

我选择了一个新创建的 maven webapp 项目,并想用它来做最简单的 mvc 应用程序。我的环境看起来像这样:

<artifactId>spring-core</artifactId>
        <artifactId>spring-test</artifactId>
        <artifactId>spring-beans</artifactId>
        <artifactId>spring-context</artifactId>
        <artifactId>spring-aop</artifactId>
        <artifactId>spring-context-support</artifactId>
        <artifactId>spring-tx</artifactId>
        <artifactId>spring-orm</artifactId>  
        <artifactId>spring-web</artifactId>
        <artifactId>spring-webmvc</artifactId>
        <artifactId>spring-asm</artifactId>
        <artifactId>log4j</artifactId>
        <artifactId>hibernate-core</artifactId>
        <artifactId>hibernate-cglib-repack</artifactId>
        <artifactId>hsqldb</artifactId>

        <!-- particular arears-->
         <dependency>
           <groupId>taglibs</groupId>
           <artifactId>standard</artifactId>
           <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>servlet-api</artifactId>
           <scope>provided</scope>
        </dependency>
        <!-- -->

       <spring.version>3.0.5.RELEASE</spring.version>
       <hibernate.version>3.6.1.Final</hibernate.version>
       <hibernate-cglig-repack.version>2.1_3</hibernate-cglig-repack.version>
       <log4j.version>1.2.14</log4j.version>
       <javax-servlet-api.version>2.5</javax-servlet-api.version>
       <hsqldb.version>1.8.0.10</hsqldb.version>
       <mysql-connector.version>5.1.6</mysql-connector.version>
       <slf4j-log4j12.version>1.5.2</slf4j-log4j12.version>
       <slf4j-api.version>1.5.8</slf4j-api.version>
       <javaassist.version>3.7.ga</javaassist.version>
       <taglibs.version>1.1.2</taglibs.version>


        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
    <finalName>admin-webapp</finalName>
</build>
<profiles>
    <profile>
        <id>endorsed</id>
        <activation>
            <property>
                <name>sun.boot.class.path</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <!-- javaee6 contains upgrades of APIs contained within the JDK itself.
                             As such these need to be placed on the bootclasspath, rather than classpath of the
                             compiler.
                             If you don't make use of these new updated API, you can delete the profile.
                             On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.-->
                        <compilerArguments>
                            <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
                        </compilerArguments>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>javax</groupId>
                            <artifactId>javaee-endorsed-api</artifactId>
                            <version>6.0</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
    <tomcat.home>${env.CATALINA_HOME}</tomcat.home>
    <web.context>${project.artifactId}</web.context>
</properties>

我的 applicationContext 就像这样简单:

<context:component-scan base-package="com.personal.springtest.admin.webapp" />
<mvc:annotation-driven />

web.xml 就像这样简单:

<web-app 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"
 version="3.0">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

<servlet>
    <servlet-name>iwadminservlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/project-admin-webapp-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

   <servlet-mapping>
    <servlet-name>iwadminservlet</servlet-name>
    <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>

我的控制器就像这样:

@Controller
public class HomeController {

   @RequestMapping(value="/")
   public String Home(){
    System.out.print("THIS IS a demo mvc, i think i like it");
    // this is temporary, will use viewresolver when everything clears up
    return "/views/home.jsp";
   }

}

我的观点是:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>JSP Page</title>
   </head>
   <body>
      <h1>Hello World!</h1>
   </body>
</html>

我得到的错误是

org.apache.jasper.JasperException:绝对 uri:http://java.sun .com/jsp/jstl/core 无法在 web.xml 或使用此应用程序部署的 jar 文件中解析

问题 1:我想知道这是否是由于我正在使用的版本造成的,我认为我读过一些有关 tomcat 中支持的版本的内容,并且使用了 java ee 版本。并没有真正从中找到解决我的问题的方法。我该如何解决这个问题?

问题 2:在此错误之前,我遇到了代码 400,因为我没有正确地将其指向 views/home.jsp,但我确实注意到,当我在netbeans,它会打开浏览器,网址为:http://localhot:8080/,而我正在期待http://localhost:8080/admin-webapp/ admin-webapp 是我的战争的名称。我认为这是一个问题并且希望解决它。

I picked up a newly created maven webapp project, and wants to do the simplest of the mvc application with it. my environment looks like so:

<artifactId>spring-core</artifactId>
        <artifactId>spring-test</artifactId>
        <artifactId>spring-beans</artifactId>
        <artifactId>spring-context</artifactId>
        <artifactId>spring-aop</artifactId>
        <artifactId>spring-context-support</artifactId>
        <artifactId>spring-tx</artifactId>
        <artifactId>spring-orm</artifactId>  
        <artifactId>spring-web</artifactId>
        <artifactId>spring-webmvc</artifactId>
        <artifactId>spring-asm</artifactId>
        <artifactId>log4j</artifactId>
        <artifactId>hibernate-core</artifactId>
        <artifactId>hibernate-cglib-repack</artifactId>
        <artifactId>hsqldb</artifactId>

        <!-- particular arears-->
         <dependency>
           <groupId>taglibs</groupId>
           <artifactId>standard</artifactId>
           <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>servlet-api</artifactId>
           <scope>provided</scope>
        </dependency>
        <!-- -->

       <spring.version>3.0.5.RELEASE</spring.version>
       <hibernate.version>3.6.1.Final</hibernate.version>
       <hibernate-cglig-repack.version>2.1_3</hibernate-cglig-repack.version>
       <log4j.version>1.2.14</log4j.version>
       <javax-servlet-api.version>2.5</javax-servlet-api.version>
       <hsqldb.version>1.8.0.10</hsqldb.version>
       <mysql-connector.version>5.1.6</mysql-connector.version>
       <slf4j-log4j12.version>1.5.2</slf4j-log4j12.version>
       <slf4j-api.version>1.5.8</slf4j-api.version>
       <javaassist.version>3.7.ga</javaassist.version>
       <taglibs.version>1.1.2</taglibs.version>


        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
    <finalName>admin-webapp</finalName>
</build>
<profiles>
    <profile>
        <id>endorsed</id>
        <activation>
            <property>
                <name>sun.boot.class.path</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <!-- javaee6 contains upgrades of APIs contained within the JDK itself.
                             As such these need to be placed on the bootclasspath, rather than classpath of the
                             compiler.
                             If you don't make use of these new updated API, you can delete the profile.
                             On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.-->
                        <compilerArguments>
                            <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
                        </compilerArguments>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>javax</groupId>
                            <artifactId>javaee-endorsed-api</artifactId>
                            <version>6.0</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
    <tomcat.home>${env.CATALINA_HOME}</tomcat.home>
    <web.context>${project.artifactId}</web.context>
</properties>

my applicationContext is as simple as:

<context:component-scan base-package="com.personal.springtest.admin.webapp" />
<mvc:annotation-driven />

web.xml as simple as so:

<web-app 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"
 version="3.0">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

<servlet>
    <servlet-name>iwadminservlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/project-admin-webapp-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

   <servlet-mapping>
    <servlet-name>iwadminservlet</servlet-name>
    <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>

my controller is just like so:

@Controller
public class HomeController {

   @RequestMapping(value="/")
   public String Home(){
    System.out.print("THIS IS a demo mvc, i think i like it");
    // this is temporary, will use viewresolver when everything clears up
    return "/views/home.jsp";
   }

}

my view is:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>JSP Page</title>
   </head>
   <body>
      <h1>Hello World!</h1>
   </body>
</html>

the error I'm getting is

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

Question 1: i'm wondering if it's due to the versions I'm using, I think I've read something about supported version in tomcat, and the java ee version used.don't really get from that a way to fix my problem. How can I fix this?

Question 2: before this error I was having code 400 because I wasn't pointing it to views/home.jsp correctly but I did notice that when I run the app in netbeans, it opens the browser with the url: http://localhot:8080/ while i was expecting http://localhost:8080/admin-webapp/ admin-webapp being the name of my war. I believe this is a problem and would like to address it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋葬我深情 2024-11-08 13:51:07

您需要 JSTL 实现:

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

或者如果您手动包含 JSTL jar:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    <scope>provided</scope>
</dependency>

You need the JSTL implementation:

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

Or if you manually include the JSTL jar:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    <scope>provided</scope>
</dependency>
眼眸里的快感 2024-11-08 13:51:07
  1. 此处下载 JSTL API 和 JSTL 实现
  2. 添加此指令:< ;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

  3. 将 JAR 文件粘贴到 WEB-INF/lib 文件夹中。这应该有效。 (它
    为我工作。)

  1. Download both the JSTL API and JSTL implementation from here
  2. Add this directive: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

  3. Paste the JAR file in your WEB-INF/lib folder. This should work. (It
    worked for me.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文