Java Code Examples for org.springframework.boot.web.servlet.ServletRegistrationBean#setInitParameters()
The following examples show how to use
org.springframework.boot.web.servlet.ServletRegistrationBean#setInitParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedServerConfig.java From secrets-proxy with Apache License 2.0 | 6 votes |
/** * Configures a custom jetty http proxy servlet based on <b>oneops.proxy.enabled</b> config * property. The proxy configuration is done on the <b>application.yaml</b> file. * * @param config OneOps config * @return {@link ServletRegistrationBean} */ @Bean @ConditionalOnProperty("oneops.proxy.enabled") public ServletRegistrationBean registerProxyServlet(OneOpsConfig config) { log.info("OneOps Http Proxy is enabled."); OneOpsConfig.Proxy proxyCfg = config.getProxy(); Map<String, String> initParams = new HashMap<>(); initParams.put(proxyTo.name(), proxyCfg.getProxyTo()); initParams.put(prefix.name(), proxyCfg.getPrefix()); initParams.put(viaHost.name(), proxyCfg.getViaHost()); initParams.put(trustAll.name(), String.valueOf(proxyCfg.isTrustAll())); initParams.put(xAuthHeader.name(), config.getAuth().getHeader()); ServletRegistrationBean servletBean = new ServletRegistrationBean(new ProxyServlet(), proxyCfg.getPrefix() + "/*"); servletBean.setName("OneOps Proxy Servlet"); servletBean.setInitParameters(initParams); servletBean.setAsyncSupported(true); log.info("Configured OneOps proxy servlet with mapping: " + proxyCfg.getPrefix()); return servletBean; }
Example 2
Source File: DruidConfig.java From springboot-learn with MIT License | 6 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); servletRegistrationBean.setServlet(new StatViewServlet()); servletRegistrationBean.addUrlMappings("/druid/*"); Map<String, String> initParameters = new HashMap<>(); initParameters.put("resetEnable", "false"); //禁用HTML页面上的“Rest All”功能 initParameters.put("allow", ""); //ip白名单(没有配置或者为空,则允许所有访问) initParameters.put("loginUsername", "admin"); //++监控页面登录用户名 initParameters.put("loginPassword", "admin"); //++监控页面登录用户密码 initParameters.put("deny", ""); //ip黑名单 initParameters.put("slowSqlMillis", "200");//执行时间大于200毫秒的都是慢sql //如果某个ip同时存在,deny优先于allow servletRegistrationBean.setInitParameters(initParameters); return servletRegistrationBean; }
Example 3
Source File: DruidConfig.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); initParams.put("allow", "");//默认就是允许所有访问 initParams.put("deny", "192.168.15.21"); bean.setInitParameters(initParams); return bean; }
Example 4
Source File: DruidDataSourceConfig.java From easyweb with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); servletRegistrationBean.setServlet(new StatViewServlet()); servletRegistrationBean.addUrlMappings("/druid/*"); Map<String, String> initParameters = new HashMap<String, String>(); // initParameters.put("loginUsername", "druid");// 用户名 // initParameters.put("loginPassword", "druid");// 密码 initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能 initParameters.put("allow", "127.0.0.1"); // IP白名单 (没有配置或者为空,则允许所有访问) // initParameters.put("deny", "192.168.20.38");// IP黑名单 // (存在共同时,deny优先于allow) servletRegistrationBean.setInitParameters(initParameters); return servletRegistrationBean; }
Example 5
Source File: DruidWebStatAutoConfiguration.java From spring-boot-starter-dao with Apache License 2.0 | 5 votes |
@Bean ServletRegistrationBean servletRegistration(DruidStatProperties druidStatConfig) { ServletRegistrationBean filterRegistration = new ServletRegistrationBean(new StatViewServlet()); filterRegistration.setAsyncSupported(true); filterRegistration.setEnabled(true); filterRegistration.addUrlMappings("/druid/*"); filterRegistration.setInitParameters(druidStatParameters(druidStatConfig)); return filterRegistration; }
Example 6
Source File: DruidServletConfig.java From cc-s with MIT License | 5 votes |
@Bean public ServletRegistrationBean druidStatViewServletBean() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), env.getProperty("druid.urlMapper")); Map<String,String> params = new HashMap<>(); params.put("loginUsername",env.getProperty("druid.loginUsername")); params.put("loginPassword",env.getProperty("druid.loginPassword")); params.put("resetEnable",env.getProperty("druid.resetEnable")); servletRegistrationBean.setInitParameters(params); return servletRegistrationBean; }
Example 7
Source File: ZkAutoConfiguration.java From zkspringboot with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(prefix = "zk", name = "springboot-packaging", havingValue = "war", matchIfMissing = false) public ServletRegistrationBean dHtmlLayoutServlet() { final String[] mappings = {"*.zul", "*.zhtml"}; ServletRegistrationBean reg = new ServletRegistrationBean(new DHtmlLayoutServlet(), mappings); reg.setInitParameters(Collections.singletonMap("update-uri", zkProperties.getUpdateUri())); reg.setLoadOnStartup(0); logger.info("ZK-Springboot: ServletRegistrationBean for DHtmlLayoutServlet with url pattern " + Arrays.asList(mappings)); return reg; }
Example 8
Source File: DruidConfig.java From Doctor with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean statViewServlet() { //配置参数参考ResourceServlet类 ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); initParams.put("allow", "");//默认就是允许所有访问 initParams.put("deny", "192.168.15.21");//拒绝谁 bean.setInitParameters(initParams); return bean; }
Example 9
Source File: DruidConfig.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
/** * Druid的servlet * * @return */ @Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet()); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "root"); initParams.put("loginPassword", "root"); initParams.put("allow", "127.0.0.1"); bean.setInitParameters(initParams); bean.setUrlMappings(Arrays.asList("/druid/*")); return bean; }
Example 10
Source File: DruidConfig.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); initParams.put("allow", "");//默认就是允许所有访问 initParams.put("deny", "192.168.15.21"); bean.setInitParameters(initParams); return bean; }
Example 11
Source File: ProxyConfiguration.java From cymbal with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(name = "proxy.prometheus.enable", havingValue = "true") public ServletRegistrationBean prometheusProxyServletRegistration() { ServletRegistrationBean registrationBean = new ServletRegistrationBean(new URITemplateProxyServlet(), "/prometheus/*"); registrationBean.setName("prometheus"); registrationBean.setInitParameters(proxyProperties.getPrometheus()); return registrationBean; }
Example 12
Source File: ProxyConfiguration.java From cymbal with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(name = "proxy.grafana.enable", havingValue = "true") public ServletRegistrationBean grafanaProxyServletRegistration() { ServletRegistrationBean registrationBean = new ServletRegistrationBean(new URITemplateProxyServlet(), "/grafana/*"); registrationBean.setName("grafana"); registrationBean.setInitParameters(proxyProperties.getGrafana()); return registrationBean; }
Example 13
Source File: DruidConfig.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); initParams.put("allow", "");//默认就是允许所有访问 bean.setInitParameters(initParams); return bean; }
Example 14
Source File: DruidConfig.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); initParams.put("allow", "");//默认就是允许所有访问 bean.setInitParameters(initParams); return bean; }
Example 15
Source File: DruidConfig.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
/** * 配置一个管理后台的Servlet */ @Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); Map<String, String> initParams = new HashMap<>(); initParams.put("loginUsername", "admin"); initParams.put("loginPassword", "123456"); //默认就是允许所有访问 initParams.put("allow", ""); bean.setInitParameters(initParams); return bean; }
Example 16
Source File: DruidConfig.java From spring-boot-demo-all with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); servletRegistrationBean.setServlet(new StatViewServlet()); servletRegistrationBean.addUrlMappings("/druid/*"); Map<String, String> initParameters = new HashMap<String, String>(); // initParameters.put("loginUsername", "druid");// 用户名 // initParameters.put("loginPassword", "druid");// 密码 initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能 initParameters.put("allow", "127.0.0.1"); // IP白名单 (没有配置或者为空,则允许所有访问) // initParameters.put("deny", "192.168.20.38");// IP黑名单 // (存在共同时,deny优先于allow) servletRegistrationBean.setInitParameters(initParameters); return servletRegistrationBean; }
Example 17
Source File: SmartDruidDataSourceConfig.java From smart-admin with MIT License | 5 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); servletRegistrationBean.setServlet(new StatViewServlet()); servletRegistrationBean.addUrlMappings("/druid/*"); Map<String, String> initParameters = new HashMap<String, String>(); //不设置用户名密码可以直接通过druid/index.html访问 if (druidLoginEnable) { initParameters.put("loginUsername", druidUserName); initParameters.put("loginPassword", druidPassword); } initParameters.put("resetEnable", "false"); servletRegistrationBean.setInitParameters(initParameters); return servletRegistrationBean; }