목차

Spring MVC

개요

MVC Service 중 Spring Web MVC를 사용한다.

설명

Configuration

web.xml

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>
			classpath*:spring/context-*.xml,
			/WEB-INF/config/egovframework/excel/context-excel.xml
	</param-value>
</context-param>
 
<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
 
<servlet>
	<servlet-name>action</servlet-name>
	<servlet-class>
		org.springframework.web.servlet.DispatcherServlet
	</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/config/egovframework/springmvc/dispatcher-servlet.xml,
			/WEB-INF/config/egovframework/springmvc/urlfilename-servlet.xml
		</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>

WEB-INF\config\egovframework\springmvc\dispatcher-servlet.xml

 <context:component-scan base-package="egovframework">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
 
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="1" 
p:viewClass="org.springframework.web.servlet.view.JstlView" 
p:prefix="/WEB-INF/jsp/egovframework/rte/" p:suffix=".jsp"/>
 
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
        <bean class="egovframework.rte.cvpl.web.common.EgovBindingInitializer"/>
    </property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>

WEB-INF\config\egovframework\springmvc\urlfilename-servlet.xml

<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>		
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
	<property name="mappings">
		<props>
			<prop key="/cvpl/EgovCvplMain.do">urlFilenameViewController</prop>
			<prop key="/cvpl/EgovCvplBottom.do">urlFilenameViewController</prop>
			<prop key="/cmmn/accessDenied.do">urlFilenameViewController</prop>
            <prop key="/cmmn/validator.js">urlFilenameViewController</prop>
		</props>
	</property>
</bean>
 
<bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>