I have sitemesh with spring working, this is the configuration: decorator.xml
Maybe it will be useful for someone, I have got the same problem, and after research in google and stading sitemesh sources, solve the problem, by extending ConfigDecoratorMapping. Here is it:
/**
* Created by IntelliJ IDEA.
* User: Inf-root
* Date: 30.06.11
* Time: 1:00
*
*/
public class ConfigDecoratorMapperSpringMvcSupport extends ConfigDecoratorMapper {
private static final Logger LOG = Logger.getLogger(ConfigDecoratorMapperSpringMvcSupport.class);
private ConfigLoader configLoader = null;
/** Create new ConfigLoader using '/WEB-INF/decorators.xml' file. */
public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException {
LOG.debug("init()...");
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());
}
}
/** Retrieve {@link com.opensymphony.module.sitemesh.Decorator} based on 'pattern' tag. */
public Decorator getDecorator(HttpServletRequest request, Page page) {
LOG.debug("getDecorator()...");
String thisPath = request.getServletPath();
LOG.debug("\tThisPath: " + thisPath);
String requestURI = request.getRequestURI();
LOG.debug("\t\tGet request URI: " + requestURI);
//TODO check indexes
thisPath = "/springURITemplate" + requestURI.substring(request.getContextPath().length(), requestURI.length() - 1);
LOG.debug("\t\t\tThisPath: " + thisPath);
String name = null;
try {
name = configLoader.getMappedName(thisPath);
}
catch (ServletException e) {
e.printStackTrace();
}
LOG.debug("\tResolved decorator name: " + name);
Decorator result = getNamedDecorator(request, name);
LOG.debug("Decorator is null ? " + (result == null));
return result == null ? super.getDecorator(request, page) : result;
}
}
and my decorators.xml contains something like this
/springURITemplate/a/administration*
Tested on tomcat 7 with Spring 3.0.5