2016년 1월 11일 월요일

spring xml 기본 사용 양식정리

*WEB-INF/config/action-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:aop="http://www.springframework.org/schema/aop"
    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
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
     /* @Controller 표현된 클래스만 빈으로 등록한다.*/
    <context:component-scan base-package="first" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    /*mvc 빈으로 등록한다.*/
    <mvc:annotation-driven>
        <mvc:argument-resolvers>
            <bean class="first.common.resolver.CustomMapArgumentResolver"></bean>
        </mvc:argument-resolvers>
    </mvc:annotation-driven>
    /* 인터셉터 설정한다.*/
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**"/>
            <bean id="loggerInterceptor" class="first.common.logger.LoggerInterceptor"></bean>
        </mvc:interceptor>
    </mvc:interceptors>
   
    <aop:aspectj-autoproxy/> <!-- @Aspect 등록 -->
    <bean id="loggerAspect" class="first.common.logger.LoggerAspect" />
     /* URL 매핑처리 하는 빈 */
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    /* context에 정의된 bean ID를 찾아서 연결 */
    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0" />
      /* JSON 처리 */
    <bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />  
     /* VIEW 이름과 실제 VIEW이름이 같을때 사용 */
    <bean
        class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="1"
        p:viewClass="org.springframework.web.servlet.view.JstlView"
        p:prefix="/WEB-INF/jsp/" p:suffix=".jsp">
    </bean>
</beans>
Share:

0 개의 댓글:

댓글 쓰기