Java 简单Servlet映射
我正在尝试在一个小应用程序上实现Spring。 我得到以下信息:Java 简单Servlet映射,java,spring,servlets,spring-mvc,Java,Spring,Servlets,Spring Mvc,我正在尝试在一个小应用程序上实现Spring。 我得到以下信息: WARNING: No mapping found for HTTP request with URI [/audiClave/] in DispatcherServlet with name 'appServlet' 这是我的web.xml文件: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/
WARNING: No mapping found for HTTP request with URI [/audiClave/] in DispatcherServlet with name 'appServlet'
这是我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<display-name>audiClave</display-name>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet- class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
返回:
HTTP Status 404
The requested resource () is not available.
我使用Tomcat7.0.12和Spring3.0.5在eclipse下运行。内容似乎已正确部署到E:\development\java.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\audiClave
当我将映射更改为/*时,它能够找到控制器,但是home.jsp无法工作,因为通配符也与之匹配
当我再次将/*从映射中取出时已解决。
谢谢只需返回“home”(而不是jsp的整个路径)。视图处理程序应配置为在该文件夹中查找具有该扩展名的视图。问题应该是:
在文件[filename]-servlet.xml中,请输入以下行:
感谢您的快速响应,但似乎没有什么帮助。我仍然收到2011年5月26日10:15:08 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound警告:在名为“appServlet”的DispatcherServlet中,找不到URI为[/audiClave/]的HTTP请求的映射。我认为它根本找不到home()方法,但它没有帮助。当我将映射更改为/*时,它能够找到控制器,但是home.jsp无法工作,因为通配符也与之匹配。你到底在使用哪个tomcat?你的应用程序部署在“webapps/audiClave”中了吗?
package com.audiClave.Service;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Handles requests for the application home page.
*/
@Controller
public class HomeController {
@RequestMapping(value = "/")
public String home() {
System.out.println("HomeController: Passing through...");
return "WEB-INF/views/home.jsp";
}
}
HTTP Status 404
The requested resource () is not available.