본문 바로가기
Developer/Spring & eGovFrame

[eGovFrame] 전자정부 국제화기능 설정 LocaleChangeInterceptor

by 순수한소년 2021. 8. 5.
728x90
반응형

/webapp/WEB-INF/config/egovframework/springmvc/egov-com-servlet.xml

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
 
    <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>
    
    <context:component-scan base-package="envi">
        <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>
    
    <!-- For Pagination Tag -->
    <bean id="imageRenderer" class="egovframework.com.cmm.ImagePaginationRenderer"/>
 
    <bean id="paginationManager" class="egovframework.rte.ptl.mvc.tags.ui.pagination.DefaultPaginationManager">
        <property name="rendererType">
            <map>
                <entry key="image" value-ref="imageRenderer"/>
            </map>
        </property>
    </bean>
 
    <!-- webBindingInitializer에서 커스터마이징 된 표준프레임워크의 클래스 -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="webBindingInitializer">
            <bean class="egovframework.com.cmm.web.EgovBindingInitializer"/>
        </property>
    </bean>
    
    <!-- setting Locale Locale Interceptor 설정하기  -->
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang" />
 
    <!-- interceptor1. 메시지 소스 설정  -->
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <property name="defaultLocale" value="ko"/>
    </bean>
    
    <!-- interceptor2. 웹로그 인터셉터 -->
    <bean id="egovWebLogInterceptor" class="egovframework.com.sym.log.wlg.web.EgovWebLogInterceptor" />
 
    <!-- interceptor3. 어드민 메뉴네비게이션 인터셉터  -->
    <bean id="adminMenuNavigstionInterceptor" class="egovframework.com.cmm.interceptor.AdminMenuNavigationInterceptor">
        <property name="permittedURL">
            <set>
                <value>/adm/adminLogin.do</value>
                <value>/adm/main.do</value>
                <value>/adm/actionLogin.do</value>
                <value>/adm/adminTop.do</value>
                <value>/adm/adminContent.do</value>
                <value>/adm/adminFooter.do</value>
            </set>
        </property>
    </bean>
    
    <!-- 인터셉터 등록 -->
    <!-- IP 정보 기록 및 로그인 체크가 필요한 URL과 로그인 여부를 체크해줄 인터셉터를 등록한다. -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean="localeChangeInterceptor"/>
                <ref bean="egovWebLogInterceptor"/>
                <ref bean="adminMenuNavigstionInterceptor" />
            </list>
        </property>
    </bean>
    
    <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="defaultErrorView" value="egovframework/com/cmm/error/egovError"/>
        <property name="exceptionMappings">
            <props>
                    <prop key="org.springframework.web.multipart.MultipartException">egovframework/com/cmm/error/multipartException</prop>
<!--                 <prop key="org.springframework.dao.DataAccessException">egovframework/com/cmm/error/dataAccessFailure</prop> -->
<!--                 <prop key="org.springframework.transaction.TransactionException">egovframework/com/cmm/error/dataAccessFailure</prop> -->
<!--                 <prop key="egovframework.rte.fdl.cmmn.exception.EgovBizException">egovframework/com/cmm/error/egovBizException</prop> -->
<!--                 <prop key="org.springframework.web.HttpSessionRequiredException">egovframework/com/uat/uia/EgovLoginUsr</prop> -->
<!--                 <prop key="egovframework.com.cmm.exception.EgovXssException">egovframework/com/cmm/error/EgovXssException</prop> -->
            </props>
        </property>
    </bean>
 
    <!-- for JFile -->
    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/>
 
    <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 id="jsonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
        <property name="contentType" value="text/html;charset=UTF-8"/>
    </bean>
    
</beans>
 
cs

@

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?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:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    
    <context:component-scan base-package="egovframework">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
    
    <context:annotation-config/>
    
    <!-- 20210712 -->
    <!-- 국제화 Message 설정 -->
    <bean id="messageSource" class="egovframework.com.cmm.util.EgovWildcardReloadableResourceBundleMessageSource">
        <property name="egovBasenames">
            <list>
                <value>classpath:/egovframework/message/com/**/*</value>
                <value>classpath:/egovframework/rte/fdl/idgnr/messages/idgnr</value>
                <value>classpath:/egovframework/rte/fdl/property/messages/properties</value>
                <value>classpath:/egovframework/egovProps/globals</value>
            </list>
        </property>
         
        <property name="cacheSeconds">
            <value>60</value>
        </property>
    </bean>
 
    <bean id="egovMessageSource" class="egovframework.com.cmm.EgovMessageSource">
        <property name="reloadableResourceBundleMessageSource">
            <ref bean="messageSource" />
        </property>
    </bean>
    
    <!-- 실행환경에서 빈 이름 참조(AbstractServiceImpl) -->
    <bean id="leaveaTrace" class="egovframework.rte.fdl.cmmn.trace.LeaveaTrace">
        <property name="traceHandlerServices">
            <list>
                <ref bean="egov.traceHandlerService" />
            </list>
        </property>
    </bean>
 
    <bean id="egov.traceHandlerService" class="egovframework.rte.fdl.cmmn.trace.manager.DefaultTraceHandleManager">
        <property name="reqExpMatcher">
            <ref bean="egov.antPathMater" />
        </property>
        <property name="patterns">
            <list>
                <value>*</value>
            </list>
        </property>
        <property name="handlers">
            <list>
                <ref bean="egov.defaultTraceHandler" />
            </list>
        </property>
    </bean>
 
    <bean id="egov.antPathMater" class="org.springframework.util.AntPathMatcher" />
    <bean id="egov.defaultTraceHandler" class="egovframework.rte.fdl.cmmn.trace.handler.DefaultTraceHandler" />
 
    <!-- MULTIPART RESOLVERS -->
    <!-- regular spring resolver -->
    <bean id="spring.RegularCommonsMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="600000000" />
        <property name="maxInMemorySize" value="100000000" />
    </bean>
 
    <!-- custom multi file resolver -->
    <bean id="local.MultiCommonsMultipartResolver" class="egovframework.com.cmm.web.EgovMultipartResolver">
        <property name="maxUploadSize" value="100000000" />
        <property name="maxInMemorySize" value="100000000" />
    </bean>
 
    <!-- choose one from above and alias it to the name Spring expects -->
    <!-- alias name="local.MultiCommonsMultipartResolver" alias="multipartResolver" /-->
    <alias name="spring.RegularCommonsMultipartResolver" alias="multipartResolver" />
 
</beans>
 
cs

 

https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte:ptl:internationalization 

 

egovframework:rte:ptl:internationalization [eGovFrame]

전자정부 표준 프레임워크에서는 Spring MVC 에서 제공하는 LocaleResolver를 이용한다. 우리는 여기서 LocaleResolver를 알아보고 적용하는 설정과 다국어가 적용된 message resource 를 가져와 활용하는 것을

www.egovframe.go.kr

 

728x90
반응형