spring的国际化


在java代码中可以这样使用国际化:
ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml");
str = ctx.getMessage("chengang", null, new Locale("zh", "CN"));


在jsp的页面上可以通过标签使用国际化:
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:message key="welcome.title"/>


使用的前提:
在配置文件中写入:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
		<property name="basename" value="/WEB-INF/messages/messages" />
		<property name="cacheSeconds" value="0" />
	</bean>





猜你喜欢

转载自huangyunbin.iteye.com/blog/1885781