나는 여기 몇 가지 튜토리얼과 다른 도움을 stackoverflow에서 확인했지만이 성가신 문제를 해결할 수 없다. 즉, 단계적으로 튜토리얼을 this 다음에 Eclipse에서 스프링 MVC 프로젝트를 만들었다. Tomcat 서버에서 자원을 찾을 수 없습니다.스프링 MVC 튜토리얼이 작동하지 않는다
WEB-INF/web.xml을 :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<!-- Processes application requests -->
<servlet>
<servlet-name>onlab</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>onlab</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
WEB-INF/onlab-servlet.xml 파일 :
@Controller
public class HomeController {
@RequestMapping(value = "/")
public String home() {
System.out.println("HomeController: Passing through...");
return "home";
}
}
WEB/HomeControllerJava
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
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="controller" />
<mvc:annotation-driven />
</beans>
SRC/제어기 -INF/views/home.jsp :
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
012 3,516,
마지막 SRC/컨트롤러/Configurer.java이 같은 튜토리얼 나를 위해 잘 작동하지만, 지금은 그냥 아파치에서 찾을 수없는 자원을 점점 계속
@Configuration
public class Configurer {
@Bean
ViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
마지막 시간입니다.
요청한 URL은 무엇입니까? –
실수입니까? 또는 폴더 WEB-ING /를 (를) 호출 했습니까? 그것의 이름을 바꾸려면 문제를 해결할 수 있습니다. WEB-INF – Tony
전체 스택 추적이 좋을 것입니다. – cbach