`

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>





  • 大小: 8.6 KB
0
4
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics