사용자 도구

사이트 도구


spring:mvcproject

문서의 이전 판입니다!


Spring MVC Proejct

  1. Spring Legacy Project를 생성
  2. Spring MVC Project의 구조
    1. 컨트롤러와 서비스, DAO, Mapper XML, logging XML파일로 채워질 Java Source 디렉토리
    2. 서블릿설정파일, JSP페이지파일, js파일, 각 종 이미지 및 관련파일등이 채워질 Servlet관련 디렉토리
    3. WEB-INF폴더에 있는 web.xml파일로 가봅시다.

WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 
	<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/root-context.xml</param-value>
	</context-param>
 
	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
 
	<!-- Processes application requests -->
	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
				/WEB-INF/spring/appServlet/servlet-context.xml
				classpath:mybatis.xml
			</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
 
	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
 
</web-app>
  1. contextConfigLocation
    • bean의 설정파일
    • DB에 대한 bean
  2. appServlet
    • DispatcherServlet의 설정파일
    • MVC구조중 C에 해당하는 설정파일로 맵핑된 jsp파일에 맞는 컨트롤러를 찾아주는 역할을 합니다.
  3. servlet-mapping
    • url-pattern을 지정(보통 *.do, *.action등을 사용하죠)
  4. filter
  5. listener
spring/mvcproject.1533198986.txt.gz · 마지막으로 수정됨: 2025/04/15 10:05 (바깥 편집)