以下のコードを実行中に404エラーが発生しました。すべてここでうまく見えますが、私はまだ404エラーを取得しています。私はこれを解決するのに役立ちます。Spring MVCのHelloプログラム
の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"
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>Hello Spring</display-name>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app><br/>
ハローservlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan basepackage="com.hello"/>
<bean class="org.springframework.web.servlet.view.InternalResouceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp"/>
</bean>
</beans></br>
HelloController
@Controller
@RequestMapping
public class HelloController {
@RequestMapping("/hello")
public ModelAndView getHello()
{
return new ModelAndView("hellopage","hellomessage","Welcome Spring MVC!!!");
}
}</br>
hellopage
<html>
<body>
<h1>${hellomessage}</h1>
</body>
</html>
あなたが使用しているスプリングジャーのバージョンは何ですか? –
プロジェクト名とコントローラクラスのパッケージ名は何ですか? –
見つかったhttp://www.tutorialsdesk.com/2016/01/spring-mvc-hello-world-tutorial-with.html Spring MVCのHello Worldサンプルの例 –