根据配置控制是否过滤

This commit is contained in:
RuoYi
2019-06-01 14:12:40 +08:00
parent bff44efcb0
commit 55a4bfe70c
5 changed files with 17 additions and 11 deletions

View File

@ -63,6 +63,7 @@ public class DruidConfig
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
{
// 获取web监控页面的参数
@ -74,6 +75,10 @@ public class DruidConfig
// 创建filter进行过滤
Filter filter = new Filter()
{
@Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
{
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
@ -88,6 +93,10 @@ public class DruidConfig
text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text);
}
@Override
public void destroy()
{
}
};
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(filter);