如何在wicket中自定义属性文件夹 [英] How to customized properties folder in wicket

查看:97
本文介绍了如何在wicket中自定义属性文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我大约有20页,每页每种语言都有大约4个属性文件.现在,所有属性都必须与*放在同一目录中. java文件.有改变的选择吗?我想创建新的目录属性,然后在此处添加所有属性文件.还是有将所有本地化消息添加到一个文件中的选项?问题是,在页面a.hmtl属性中,名称"具有值"a",而在另一页面b.html中具有相同的键的另一个值是:名称"值"b"

in my application I have about about 20 pages, Each page have about 4 properties file for each language. Now all properties have to be in same directory as is *. java file. Is there option to change in ? I want to create new directory properties and here add all properties file. Or is there option to add all localized message in one file ? Problem is that in page a.hmtl properties "name" has value "a" and in another page b.html has the same key another value: "name" value "b"

我尝试添加

        this.getResourceSettings().addResourceFolder("/properties");

但没有成功

推荐答案

我没有找到更简单的解决方案.我编写了自己的类,在其中更改了属性的路径:

I didnt find easier solution. I write my own class where I changing path to my properties:

package org.toursys.web.finder;

import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.locator.ResourceStreamLocator;

public class CustomResourceStreamLocator extends ResourceStreamLocator {

    @Override
    protected IResourceStream locateByClassLoader(Class<?> clazz, final String path) {
        String newPath = path;
        if (newPath.endsWith(".properties")) {
            newPath = path.substring(0, path.lastIndexOf("/")) + "/properties" + path.substring(path.lastIndexOf("/"));
        }
        IResourceStream stream = super.locateByClassLoader(clazz, newPath);
        if (stream == null) {
            stream = super.locateByClassLoader(clazz, path);
        }
        return stream;
    }

}

然后将这个流定位器添加到我的应用中

and then I add this stream locator to my app

这篇关于如何在wicket中自定义属性文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆