我有一個簡單的Spring MVC應用程序。我得到了HTTP狀態404的報告。幫我解決這個問題。謝謝。爲什麼Spring MVC獲得404?
HTTP狀態404 - 找不到
類型狀態報告
消息/WEB-INF/users_view.jsp
說明原始服務器沒有找到當前表示 目標資源或不願意透露存在。
的Apache Tomcat/9.0.0.M26
我的控制器:
@Controller
public class UserController {
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String showUsers(ModelMap model) {
return "users_view";
}
}
項目結構:
我web.xml
:
<display-name>User</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.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>
<!-- Process application servlet -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
而且applicationContext.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation= "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">
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/"/>
<property name="suffix" value=".jsp"/>
</bean>
<context:component-scan base-package="ru.pravvich" />
</beans>