저는 Spring MVC 3.0을 처음 접하는 사람들이며 느낌을 얻기 위해 샘플 webapp를 작성하려고합니다. 브라우저에 출력으로 표시된 바와 같이 나는 어떤에서 내 JSP 자원에 요청을 전달하실 수 내 관련 컨트롤러를 호출하는 URL을 얻을 수 있지만 이니spring3.0 mvc 문제 (요청한 리소스를 사용할 수 없음)
요청 된 자원 (/ Spring30HelloWorld/helloworldcontroller) 을 사용할 수 없습니다.
문제 해결에 대한 제안은 감사하겠습니다. 내 코드 설정에 대해서는 아래를 참조하십시오. 사전에
감사합니다!
web.xml의 (위치 /의 WebContent)
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Spring30HelloWorld</display-name>
<servlet>
<servlet-name>A</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>A</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
A-servlet.xml 파일 (위치 /의 WebContent/WEB-INF /)
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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 base-package="com.controller" />
</beans>
HelloWorldController.java (위치/SRC/COM/제어기)
package com.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
@Controller
public class HelloWorldController {
@RequestMapping("/helloWorld")
public ModelAndView sayHello() {
System.out.println("hello!");
//return new ModelAndView("helloworld.jsp", "hello", "hello");
return new ModelAndView("helloworld.jsp");
}
}
HelloWorld.jsp를 (위치 /의 WebContent /)
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Simple Spring 3.0 Web App</h1>
<p></p>
</body>
</html>
지금 문제를 발견했습니다. ModelAndView의 네임 스페이스는 포틀릿 대신 서블릿이어야합니다. 어쨌든 귀하의 의견에 감사드립니다! – Daniel