Java 带404错误页的spring mvc项目
我不明白是什么问题 我的运行时环境:Java 带404错误页的spring mvc项目,java,spring,jsp,spring-mvc,tomcat,Java,Spring,Jsp,Spring Mvc,Tomcat,我不明白是什么问题 我的运行时环境: sts-3.7.2 maven 3.0.5 雄猫7 java 1.8 我制作了“SpringMVC项目”,项目名为“SpringTest”,顶级包名为“com.javalec.SpringTest” 我运行tomcat服务器并输入“”! 但是,输出页面是“404错误页面””说的 HTTP状态404-/springtest/WEB-INF/views/home.jsp 消息:/springtest/WEB-INF/views/home.jsp 说明请求
- sts-3.7.2
- maven 3.0.5
- 雄猫7
- java 1.8
HTTP状态404-/springtest/WEB-INF/views/home.jsp 消息:/springtest/WEB-INF/views/home.jsp 说明请求的资源不可用 ApacheTomcat/7.0.67
和控制台已打印 信息:com.javalec.springtest.HomeController-欢迎回家!客户端区域设置为en_US
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 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>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.javalec.springtest" />
</beans:beans>
home.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>
Hello world!
</h1>
<P> The time on the server is ${serverTime}. </P>
</body>
</html>
家
你好,世界!
服务器上的时间为${serverTime}
我在控制台框中看不到任何错误消息。。。
我只能看到404错误页面。。。
我输入了正确的上下文地址“”
有什么问题吗?您可以共享home.jsp的路径吗?home.jsp是“SpringTest/src/main/webapp/WEB-INF/views/home.jsp”?
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>
Hello world!
</h1>
<P> The time on the server is ${serverTime}. </P>
</body>
</html>