You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring表单标签JasperException异常求助:URI无法解析

Tomcat运行Spring MVC应用时JasperException无法解析Spring Form标签URI

我已经折腾这个问题快一周了,搜遍了能找到的解决方案都没搞定,实在没头绪了,来这儿求各位大佬给点线索!

我在运行包含add.jsp的Tomcat Spring MVC应用时,遇到了这个异常:

JasperException: The absolute uri: [http://www.springframework.org/tags/form] cannot be resolved in either web.xml or the jar files deployed with this application.

我的开发环境

  • IntelliJ IDEA 2018.1.3(旗舰版)
  • JRE: 1.8.0_152-release-1136-b38 amd64
  • apache-tomcat-9.0.8

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">
  <parent>
    <artifactId>movie</artifactId>
    <groupId>com.moviedatabase</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>movie-webapp</artifactId>
  <packaging>war</packaging>
  <dependencies>
    <dependency>
      <groupId>com.moviedatabase</groupId>
      <artifactId>movie-application</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.validator</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>6.0.9.Final</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.1</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

web.xml代码

<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>Baza filmów</display-name>
  <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <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>
</web-app>

add.jsp代码

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!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>Dodaj film</title>
</head>
<body>
<a href="list.jsp">Powrót do listy filmów</a><br />
<form:form method="POST" modelAttribute="movieDto">
  <table border="1">
    <tbody>
    <tr>
      <th>Tytuł</th>
      <td><form:input type="text" path="title"/><c:if test="${pageContext.request.method=='POST'}"><form:errors path="title"/></c:if></td>
    </tr>
    <tr>
      <th>Autor</th>
      <td><form:input type="text" path="author"/><c:if test="${pageContext.request.method=='POST'}"><form:errors path="author"/></c:if></td>
    </tr>
    <tr>
      <th>Rok wydania</th>
      <td><form:input type="text" path="year"/><c:if test="${pageContext.request.method=='POST'}"><form:errors path="year"/></c:if></td>
    </tr>
    <tr>
      <td colspan="2">

内容的提问来源于stack exchange,提问作者Mskat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:30:46