Java Eclipse项目2中的HTTP 404错误
我正在尝试学习如何在服务器上运行SpringMVC项目,但遇到了一个HTTP404错误。。我正在使用EclipseLuna4.4.1和Tomcat8 我看不到错误 控制器类Java Eclipse项目2中的HTTP 404错误,java,spring,jsp,Java,Spring,Jsp,我正在尝试学习如何在服务器上运行SpringMVC项目,但遇到了一个HTTP404错误。。我正在使用EclipseLuna4.4.1和Tomcat8 我看不到错误 控制器类 package com.spring.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping;
package com.spring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class OffersController {
@RequestMapping("/")
public String showHome() {
return "home";
}
}
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
<body>
Hi there!
</body>
</html>
在此处插入标题
你好!
Ther Servlet
<?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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans ://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="com.maurice.controllers">
</context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
bean 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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans ://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
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_2_5.xsd" id="WebApp_ID"
version="2.5">
<display-name>Own2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet- class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
拥有2
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
提供
提供
org.springframework.web.servlet.DispatcherServlet
1.
提供
/
我看到控制器的包是(com.spring.controller),但是您正在扫描另一个包(base package=“com.maurice.controllers”)!!!ups我更改了这个上传的包名,但忘记了这个,但这不是错误的来源。那么spring配置文件的名称是什么?它应该是WEB-INF/offers-servlet.xml它是WEB-INF/offers-servlet.xml我看到控制器的包是(com.spring.controller),但是您正在扫描另一个包(base package=“com.maurice.controllers”)!!!ups我更改了这个上传的包名,但忘记了这个,但这不是错误的来源。那么spring配置文件的名称是什么?它应该是WEB-INF/offers-servlet.xml它是WEB-INF/offers-servlet.xml