2012-02-15 2 views
-2

web.XML과 같은 Web-inf 폴더에 넣을 기본적인 XML 구성 파일과 뷰 해석기 bean 작성 위치를 알아야합니다.기본 Spring MVC 애플리케이션을 실행할 구성 또는 xml 파일은 무엇입니까?

컨트롤러를 어떻게 등록합니까?

응용 프로그램을 실행할 때 "서블릿 컨텍스트 자원을 열 수 없습니다"라는 오류 메시지가 나타납니다. 서블릿 컨텍스트 리소스 란 무엇이며 어디에 언급해야합니까?

내 web.xml 파일은 다음과 같습니다

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

<servlet> 
<servlet-name>springmvc</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
<servlet-name>springmvc</servlet-name> 
<url-pattern>*.html</url-pattern> 
</servlet-mapping> 
<welcome-file-list> 
<welcome-file> 
jsp/index.jsp 
</welcome-file> 


</welcome-file-list> 
</web-app> 

내 springmvc은 다음과 같습니다

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> 

<bean name="/hello_world.html" class="springmvc.web.HelloWorldController"/> 
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> 
<property name="prefix" value="/jsp/"/> 
<property name="suffix" value=".jsp"/> 
</bean> 
</beans> 

나는 단지이 두 개의 XML 파일이 있습니다.

스프링 구성 파일도 필요하다는 것을 알고 있습니다. 나는 그것을 넣어야 할 세부 사항을 모른다.

+2

봄은 아주 좋은 문서를 가지고 있습니다. 아마 읽어야 할 것입니다. – bezmax

+0

@Max 참고 문서 (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/)도 좋습니다. 그러나 불행히도이 문서는 응용 프로그램을 설정하는 방법을 설명하지 않습니다. – Ralph

답변

0

STS (Spring Tool Suite)를 사용하는 경우 스프링 템플릿 프로젝트를 만들 수 있습니다. (새 프로젝트/SpringSource Tool Suite/Spring 템플릿 프로젝트/-Spring MVC 프로젝트)

여기에는 시작해야하는 모든 파일이 포함되어 있습니다.

관련 문제