6

我收到 Apche tile 3 和 Spring MVC 4 的以下警告我没有为多语言支持添加任何额外的配置,但它默认支持。任何人都可以帮助我禁用此选项以在我的站点中删除此警告。

    org.apache.tiles.request.locale.PostfixedApplicationResource.
<init> No supported matching language for locale "sw". 
Using file:/opt/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/tiles/app-core_sw.xml as a non-localized resource path. see TILES-571
4

2 回答 2

6

您可以通过编写自己的DefinitionFactory实现并在TilesConfigurer.

public class CustomLocaleDefinitionsFactory extends LocaleDefinitionsFactory {

    /** {@inheritDoc} */
    @Override
    public Definition getDefinition(String name, Request tilesContext) {
    Definition retValue;
    Locale locale = null;

    retValue = definitionDao.getDefinition(name, locale);
    if (retValue != null) {
      retValue = new Definition(retValue);
      String parentDefinitionName = retValue.getExtends();
      while (parentDefinitionName != null) {
        Definition parent = definitionDao.getDefinition(parentDefinitionName, locale);
        if (parent == null) {
          throw new NoSuchDefinitionException("Cannot find definition '" + parentDefinitionName
              + "' ancestor of '" + retValue.getName() + "'");
        }
        retValue.inherit(parent);
        parentDefinitionName = parent.getExtends();
      }
    }

    return retValue;
    }
}

然后在注册上面定义的因子类,TilesConfigurer以防这样使用spring。

TilesConfigurer configurer = new TilesConfigurer();
configurer.setDefinitions(new String[] { "/WEB-INF/layouts/tiles.xml",
    "/WEB-INF/views/**/tiles.xml" });
configurer.setCheckRefresh(true);
configurer.setDefinitionsFactoryClass(CustomLocaleDefinitionsFactory.class);
return configurer;
于 2016-11-21T22:06:41.020 回答
1

有一个解决方法,只要禁用日志输出就可以了,如果你使用的是spring boot,很简单:

logging.level.org.apache.tiles.request.locale.PostfixedApplicationResource=ERROR
于 2018-07-26T10:30:08.263 回答