我使用sitemesh来装饰我的应用程序。并配置一个decorator.xml,如下所示,使一些url不被sitemesh装饰。
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/decorators">
<excludes>
<pattern>/xxx/merchant/getimage</pattern>
</excludes>
<decorator name="centralized">
<pattern>/*</pattern>
</decorator>
</decorators>
我使用过滤器动态控制sitemesh装饰。我怎么知道decorator.xml中使用API的排除模式。
public class NewMenuFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) {
}
@Override
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
String contextPath =
((HttpServletRequest) request).getRequestURI();
// if contextPath is match excludes pattern
request.setAttribute("Header_HeadType", "XXX");
//else
request.setAttribute("Header_HeadType", "YYY");
chain.doFilter(request, response);
}
}