如何在过滤器中动态删除sitemesh exclude config?

时间:2016-08-19 13:15:36

标签: java struts2 freemarker sitemesh

我有一个像这样的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

0 个答案:

没有答案