---
title: "Tapestry5国际化资源文件的优先级"
author: "tapestry"
date: "2010-05-13T10:34:28Z"
tags: []
categories: ["企业架构"]
slug: "tapestry5"
draft: false
lastmod: "2010-05-13T10:34:28Z"
id: 665391
url: "https://tapestry.iteye.com/blog/665391"
---

今天(20100512)Tapestry5增加了新的功能，支持多个国际化资源文件，默认的为app.properties，现在可以增加多个资 源文件例如pre-app.properties,具体的配置如下，在AppModule中增加如下配置：

 

```
public static void contributeComponentMessagesSource(
            @Inject @Value("context:WEB-INF/pre-app.properties") Resource preappResource,
            OrderedConfiguration<Resource> configuration) {

        configuration.add("PreApp", preappResource, "before:AppCatalog");
    }
```

 

这样就增加了一个国际化资源文件pre-app.properties，在app.properties中如果有跟pre- app.properties中一样的配置，以app.properties中的为准。

     单个页面类或者组件类中可以单独以类名字来定义资源文件，例如一个页面类Test.java中有个textfield的id为nameField，可以在 Test.java同目录下定义个资源文件Test.properties，如果nameField的验证为required的话，设定显示的错误信息为 nameField-required-message=请输入您的姓名，但是如果app.properties中也包含这个nameField- required-message的key的话，以app.properties为主，看来还是app.properties优先级高呀。