<spring:message code="msg.x.x.x" />
使用FastPageParser在裝飾器上適用於我。
幾件事情來檢查..
所以在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:消息呢?
來源
2012-02-02 17:32:21
raq