Commit bcce0ba7 authored by Quxl's avatar Quxl

x

parent a36ea402
......@@ -15,12 +15,15 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.alibaba.druid.util.Utils;
import com.alibaba.druid.wall.WallConfig;
import com.alibaba.druid.wall.WallFilter;
@Configuration
@ConditionalOnWebApplication
......@@ -36,7 +39,8 @@ public class DruidConfig {
final String filePath = "support/http/resources/js/common.js";
Filter filter = new Filter() {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
chain.doFilter(request, response);
response.resetBuffer();
String text = Utils.readFromResource(filePath);
......@@ -50,22 +54,39 @@ public class DruidConfig {
registrationBean.addUrlPatterns(commonJsPattern);
return registrationBean;
}
@Bean
public FilterRegistrationBean<Filter> webStatFilterRegistrationBean(DruidStatProperties properties) {
WebStatFilter filter = new WebStatFilter();
FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<Filter>();
registrationBean.setFilter(filter);
registrationBean.addUrlPatterns("/*");
registrationBean.addInitParameter("exclusions", "*.js, *.gif, *.jpg, *.bmp, *.png, *.css, *.ico, /v2/api-docs, /swagger*, /webjars/*, /druid/*");
registrationBean.addInitParameter("exclusions",
"*.js, *.gif, *.jpg, *.bmp, *.png, *.css, *.ico, /v2/api-docs, /swagger*, /webjars/*, /druid/*");
return registrationBean;
}
@Bean
public ServletRegistrationBean<?> setvletRegistrationBean() {
ServletRegistrationBean<StatViewServlet> setvletRegistrationBean = new ServletRegistrationBean<StatViewServlet>(new StatViewServlet(), "/druid/*");
ServletRegistrationBean<StatViewServlet> setvletRegistrationBean = new ServletRegistrationBean<StatViewServlet>(
new StatViewServlet(), "/druid/*");
setvletRegistrationBean.addInitParameter("resetEnable", "true");
return setvletRegistrationBean;
}
@Bean(name = "wallConfig")
WallConfig wallFilterConfig() {
WallConfig wc = new WallConfig();
wc.setMultiStatementAllow(true);
return wc;
}
@Bean(name = "wallConfig")
@DependsOn("wallConfig")
WallFilter wallFilter(WallConfig wallConfig){
WallFilter wfilter = new WallFilter ();
wfilter.setConfig(wallConfig);
return wfilter;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment