SpringMVC 国际化
2016-04-08 22:29
323 查看
web.xml
<listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
applicationContext.xml
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames"> <list> <value>format</value> <value>exceptions</value> <value>windows</value> </list> </property> <!-- 如果在国际化资源文件中找不到对应代码的信息,就用这个代码作为名称 --> <property name="useCodeAsDefaultMessage" value="true" /> </bean>
在src文件夹下面建立 format.properties exception.properties window.properties 三个资源文件()
index.jsp
<pre class="html" name="code"><%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring" %> <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> Spring mvc 国际化: <spring:message code="name"></spring:message> </body> </html>
相关文章推荐
- ubuntu14.10安装配置jdk
- Java集合中的排序API分析
- 在Java中如何遍历Map对象
- Java并发编程系列之二十七:ThreadLocal
- 初学JAVA关于设计一个倒立的正三角形
- Java 的集合+IO
- 一些不常被注意到的Java问题
- Java类型相互转换byte[]类型,blob类型
- struts2校验
- java的异常处理
- java常用类
- JAVA线程池源码探究与简单小例子
- Java课程“新”得(四)
- 开发没有直径,但也要避免走弯路
- Java中子类的访问权限为何比父类大?
- java面向对象笔记
- IntelliJ IDEA的JDK环境配置和Maven依赖管理
- Java进阶学习第一天——HTML入门
- 浅析Java中static修饰符
- Java 序列化 反序列化 历史版本处理