저는 SpringMVC에서 새롭고 간단한 hello world 프로그램을 실행하려고합니다. 그러나, 내 브라우저 (http://localhost:8080/FirstspringMVCwithannotation/welcome)에서 이것을 실행하면 HTTP Status-404 Error가 발생합니다.봄 MVC에서 오류 (HTTP 상태 404 -) 받기
HelloController.java
package com.example;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
@Controller
public class HelloController {
@RequestMapping("/welcome")
public ModelAndView helloWorld(){
ModelAndView model=new ModelAndView("HelloPage");
model.addObject("msg","hello world");
return model;
}
}
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>FirstspringMVCwithannotation</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
스프링 운영자-servlet.xml에
<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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.example" />
<mvc:annotation-driven/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
HelloPage.jsp
: 여기서, 코드는<html>
<body>
<h1>
First Spring MVC Application Demo
</h1>
<h2>
${msg}
</h2>
</body>
</html>
여기
내 프로젝트 구조이며, 나는 다른 솔루션을 참조하려고
lib 폴더 아래의 모든 스프링 jar 파일을 추가하지만, 내 problem..can 사람이 제발 도와 해결되지 않는 이유는 HTTP 상태 - 404 오류가 발생합니까? 미리 감사드립니다.
가'/ URL 패턴>'을 변경해보십시오'/* URL 패턴>', http://stackoverflow.com/questions/29792677 –
'@RequestMapping ("/ 환영")를 참조 '오류 이유를'/'로 바꾸어 작업을하거나 우스꽝스러운 코멘트를 남깁니다 – emotionlessbananas
프로젝트 파일 구조 란 무엇입니까? jsp 뷰가 위치한 폴더 경로는 무엇입니까? –