我有一个像这样的sitemesh decorator.xml:
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/decorators">
<excludes>
<pattern>/merchant/brand/*</pattern>
<pattern>/merchant/spu</pattern>
</excludes>
<decorator name="centralized">
<pattern>/*</pattern>
</decorator>
我使用过滤器动态控制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();
//todo:if new contextPath,remove the sitemesh exclude config
request.setAttribute("Header_HeadType", "XXX");
//else
request.setAttribute("Header_HeadType", "YYY");
chain.doFilter(request, response);
}
如何在过滤器中动态删除sitemesh排除配置,例如删除<pattern>/merchant/spu</pattern>
使用API中的todo:if new contextPath,remove the sitemesh exclude config
。