我没有找到调度程序servelt 的映射。能否请您指出代码中的问题所在。我对 Spring MVC 很陌生
我的错误是(我的 pom 有 EnhancedRoyaltyTool 的 artifactId)
No mapping found for HTTP request with URI [/EnhancedRoyaltyTool/] in DispatcherServlet with name 'mvc-dispatcher
我的 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>Spring Web MVC Application</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/mvc-dispatcher-servlet.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>
<!-- <listener> -->
<!-- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> -->
<!-- </listener> -->
</web-app>
我的 mvc-dispatcher-servlet.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.acxiom.saas.royalty.controller"/>
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
我的控制器文件
@Controller
public class SearchController
{
@ModelAttribute("search")
public Search getSearch()
{
return new Search();
}
@RequestMapping(value ="/")
public String homePage()
{
System.out.println("home");
return "search";
}
@RequestMapping(value ="/payRoyalties", method = RequestMethod.POST)
public String searchJobs(ModelMap model, @ModelAttribute("search") Search search)
{
System.out.println(search.getOesNumber() +"TEST");
model.addAttribute("test", "testing modelmap");
return "payRoyalties";
}
}
我的 search.jsp 文件
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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=ISO-8859-1">
<title>Search For Jobs</title>
</head>
<body>
<form:form method="POST" modelAttribute="search" action="payRoyalties" >
<table>
<tr>
<td><form:label path="oesNumber">OES Number</form:label></td>
<td><form:input path="oesNumber" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Search" /></td>
</tr>
</table>
</form:form>
</body>
</html>
我确实有一个 payRoyalties.jsp 文件和搜索模型。