note

LocaleChangeInterceptor를 이용한 Locale 변경(국제화) 본문

JSP/Spring

LocaleChangeInterceptor를 이용한 Locale 변경(국제화)

투한 2012. 3. 7. 10:35





















dispatcherInternal-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/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"
	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">

	<!-- 커스텀 태그 이용 -->
 	<bean class="madvirus.spring.chap07.controller.LoginController">
 		<property name="authenticator">
 			<bean class="madvirus.spring.chap07.controller.MockAuthenticator"/>
 		</property>
 	</bean>
 	
	<!-- 국제화 2 -->
	<bean id="localeChangeInterceptor"
		class="madvirus.spring.chap07.controller.LocaleChangeController"
				p:paramName="language" />
	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
		<property name="interceptors">
			<list>
				<ref bean="localeChangeInterceptor"/>
			</list>
		</property>
	</bean>
	
	
	<!-- View 글로벌 설정 -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/viewjsp/" />
		<property name="suffix" value=".jsp"/>
	</bean>
	
	<!-- 리소스 번들 지정 -->
	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
		<property name="basenames">
			<list>
				<value>messages.validation</value>
				<value>messages.label</value>
			</list>
		</property>
	</bean>
</beans>



이전 방식보다 간편한 방법입니다