---
title: "Spring3 mvc 国际化时的一点注意"
author: "BestUpon"
date: "2010-12-13T09:37:52Z"
tags: []
categories: ["企业架构"]
slug: "spring3-mvc"
draft: false
lastmod: "2010-12-13T09:37:52Z"
id: 840481
url: "https://bestupon.iteye.com/blog/840481"
---

Spring3 MVC 中：如果使用国际化的形式，如果采用如下形式：

 

```
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		HttpSession session = se.getSession();
		String filePath = se.getSession().getServletContext().getRealPath("/") + FILE_NAME;
		Map<String, String> properties = readProperties(filePath);
		for (String o : properties.keySet()) {
			session.setAttribute(o, properties.get(o));
		}
	}
```

 

 将国际化的内容加载到Session，如果按照以前的国家的内容方式：

 

```
	site.name = 开发测试名称——Framewrok
	site.copyright= XXXXX
```

 的形式书写，在页面采用${site.name},${site.copyright}获取国际化的内容是拿不到的值得，原因是：Spring 3

 

采用的是Model 和ModelMap 的有限级别，session的优先级别最低，所以中间有“.”的时候，会在Model或ModelMap

中去寻找，没有寻找到，就认为是不存在，就不显示。为了避免如此我们应该用如下格式：

 

```
	site_name = 开发测试名称——Framewrok
	site_copyright= XXXXX
```