在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>