zoukankan      html  css  js  c++  java
  • jboss下部署失败,原因是i18n配置文件读取错误,改为如下

    public class I18nResourceBundleMessageSource extends

    ResourceBundleMessageSource {


    private static Log log = LogFactory

    .getLog(I18nResourceBundleMessageSource.class);


    /**

    * 重载父类的方法 ,支持在WEB-INF/classes下 以 basename

    * 来匹配国际化资源文件,basename取值一般是message_*.properties

    * 要求国际化资源文件 是这个格式:message_模块名_实体名_locale.properties

    */

    @Override

    public void setBasename(String basename) {

    try {

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

    // 通过模式匹配加载多个模式匹配的Resource

    Resource[] resources = resolver

    .getResources("classpath*:message_*.properties");

    Set<String> baseNameSet = new HashSet<String>();

    for (int i = 0; i < resources.length; i++) {

    Resource r = resources[i];

    String fileName = r.getFilename();

    log.info("Reading i18n properties: " + fileName);


    Pattern p = Pattern.compile("message_[a-zA-Z]+_[a-zA-Z]+");

    Matcher matcher = p.matcher(fileName);

    if (matcher.find()) {

    fileName = matcher.group();

    baseNameSet.add(fileName);

    }

    }


    String[] baseNames = (String[]) baseNameSet

    .toArray(new String[baseNameSet.size()]);

    setBasenames(baseNames);

    } catch (IOException ex) {

    throw new SystemException("Reading i18n properties error.", ex);

    }


    /*

    * List<String> baseNameList = new ArrayList<String>(); String path =

    * ""; try { path = CommUtil.getInstance().getWebInfPath(); } catch

    * (IllegalAccessException e) { throw new

    * SystemException("获取国际化文件路径出错",e); }

    * //File dir = new File( path + "classes/i18n" ); File dir = new File(

    * path + "classes" );

    * FileFilter fileFilter = new WildcardFileFilter(basename); File[]

    * files = dir.listFiles(fileFilter); String fileName = null; try { for

    * (int i=0;i< files.length;i++){ fileName = files[i].getName(); int

    * index = fileName.indexOf("_"); index = fileName.indexOf("_",

    * index+1); index = fileName.indexOf("_", index+1);

    * //fileName = "i18n/" +fileName.substring(0,index); fileName =

    * fileName.substring(0,index);

    * if (! baseNameList.contains(fileName)) { baseNameList.add(fileName);

    * } } } catch (Exception e) { throw new SystemException("读取国际化资源文件" +

    * fileName + "出错",e); }

    * String[] baseNames = (String[]) baseNameList.toArray(new

    * String[baseNameList.size()]); setBasenames(baseNames);

    */

    }



    }


  • 相关阅读:
    Mysql复制表格
    MySql的导入与导出
    jQuery语法
    JavaScript中的test()方法
    Android解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget(转)
    Android图片压缩方法总结
    Android实现app长时间未操作时自动退出app
    银行卡号的检测
    Android大图片裁剪终极解决方案(上:原理分析)
    Windows环境下Android Studio v1.0安装教程
  • 原文地址:https://www.cnblogs.com/danghuijian/p/4399999.html
Copyright © 2011-2022 走看看