2012-02-02 8 views
0

Sitemesh 2のプロジェクトでspring:messageタグを使用しています。 デコレータのspring:メッセージが-tagよりも認識されません。 jspページではなく、デコレータjspファイルで-tagを使用できます。Sitemesh spring:テンプレートでメッセージが認識されない

<?xml version="1.0" encoding="UTF-8"?> 

<excludes/> 

<page-parsers> 
    <parser content-type="text/html" encoding="UTF-8" class="com.opensymphony.module.sitemesh.parser.FastPageParser" /> 
</page-parsers> 

<decorator-mappers> 
    <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper"> 
     <param name="config" value="${decorators-file}" /> 
    </mapper> 
</decorator-mappers> 

であるよりも、我々は問題がないよりも、非推奨パーサーFastPageParserを使用する場合は、新しいHTMLPageParserを使用している場合は動作しません。

どうすればこの問題を解決できますか?

答えて

0
<spring:message code="msg.x.x.x" /> 

FastPageParserを使用するデコレータでうまく動作します。

チェックする物事のカップル...

  • はあなたのデコレータのspringframeworkとsitemeshタグライブラリを含めていますか?

  • フィルタチェーンに違いがあるかどうかはわかりませんが、リクエストスコープに設定されたレイアウトに基づいてデコレータを選択するカスタムのコンフィグレーターマッパーを使用しています。

だからsitemesh.xmlに:

<decorator-mappers> 
    <mapper class="org.x.x.CustomConfigDecoratorMapper"> 
     <param name="config" value="${decorators-file}" /> 
    </mapper> 
</decorator-mappers> 

CustomConfigDecoratorMapperは、このようなのを見て:それ以外

public class CustomConfigDecoratorMapper extends AbstractDecoratorMapper { 

    private static final Logger logger = Logger.getLogger(CustomConfigDecoratorMapper.class); 
    private ConfigLoader configLoader = null; 

    public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException 
    { 
     super.init(config, properties, parent); 
     try 
     { 
      String fileName = properties.getProperty("config", "/WEB-INF/decorators.xml"); 
      configLoader = new ConfigLoader(fileName, config); 
     } 
     catch (Exception e) 
     { 
      throw new InstantiationException(e.toString()); 
     } 
    } 

    public Decorator getDecorator(HttpServletRequest request, Page page) 
    { 
      String layoutName = "default"; 

      String configLayoutName = (String)request.getParameter("layoutName"); 
      if (configLayoutName == null) 
      { 
        configLayoutName = (String)request.getAttribute("layoutName"); 
        if (configLayoutName == null) 
        { 
          configLayoutName = "default"; 
        } 
      } 
      if (configLayoutName != null) 
      { 
        layoutName = configLayoutName; 
      } 

      Decorator result = getNamedDecorator(request, layoutName); 
      return result == null ? super.getDecorator(request, page) : result; 
    } 

    public Decorator getNamedDecorator(HttpServletRequest request, String name) 
    { 
      Decorator result = null; 
      try 
      { 
        result = configLoader.getDecoratorByName(name); 
      } 
      catch (ServletException e) 
      { 
        logger.error("getNamedDecorator(HttpServletRequest, String)", e); 
      } 
      if (result == null || (result.getRole() != null && !request.isUserInRole(result.getRole()))) 
      { 
        return super.getNamedDecorator(request, name); 
      } 
      else 
      { 
        return result; 
      } 
     } 
    } 

を..あなたはfmtを使用して考えた:代わりにメッセージを?

関連する問題