VVL1295

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Spring MVC 国际化(视图的国际化显示)

  其实与Spring没什么关系,就是JSP的国际化显示

  配置文件:

   <!-- 配置国际化资源 -->
   <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
       <property name="basename" value="i18n"></property>
   </bean>

  需要在src下新建一个properties文件,文件名为i18n_zh_CN.properties,文件内容如下:

   i18n.username=\u7528\u6237\u540D

  那么,在jsp要增加taglib指令:

   <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

  在JSP中的使用如下:

   <fmt:message key="i18n.username"></fmt:message>

  以上。

 

posted on 2016-10-21 11:05  bobo2018  阅读(148)  评论(0)    收藏  举报