私は単純な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>