本文整理汇总了Java中org.springframework.boot.web.servlet.ServletRegistrationBean.setInitParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRegistrationBean.setInitParameters方法的具体用法?Java ServletRegistrationBean.setInitParameters怎么用?Java ServletRegistrationBean.setInitParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.web.servlet.ServletRegistrationBean
的用法示例。
在下文中一共展示了ServletRegistrationBean.setInitParameters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerProxyServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
/**
* 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;
}
示例2: druidStatViewServletBean
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@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;
}
示例3: servletRegistrationBean
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
/**
* Spring Servlet Registration bean for StatusServlet.
*
* @return ServletRegistrationBean
*/
public ServletRegistrationBean servletRegistrationBean() {
Map<String, String> initParameters = new HashMap<>();
initParameters.put("bean", AppStatusWebConstants.BEAN_NAME);
initParameters.put("custom-pages", customPages);
ServletRegistrationBean srb = new ServletRegistrationBean();
srb.setServlet(new StatusServlet());
srb.setUrlMappings(urlMappings);
srb.setInitParameters(initParameters);
return srb;
}
示例4: servletRegistration
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@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;
}
示例5: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@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;
}
示例6: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
LOGGER.info("Initializing DruidServlet Config");
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
servletRegistrationBean.setServlet(new StatViewServlet());
servletRegistrationBean.addUrlMappings("/druid/*");
Map<String, String> initParameters = new HashMap();
initParameters.put("loginUsername", "admin");// 用户名
initParameters.put("loginPassword", "[email protected]!");// 密码
initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能
initParameters.put("allow", ""); // IP白名单 (没有配置或者为空,则允许所有访问)
//initParameters.put("deny", "192.168.20.38");// IP黑名单 (存在共同时,deny优先于allow)
servletRegistrationBean.setInitParameters(initParameters);
return servletRegistrationBean;
}
示例7: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet(){
log.info("init Druid Servlet Configuration ");
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
servletRegistrationBean.setServlet(new StatViewServlet());
servletRegistrationBean.addUrlMappings("/druid/*");
Map<String, String> initParameters = new HashMap<String, String>();
initParameters.put("loginUsername", "admin");// 用户名
initParameters.put("loginPassword", "admin");// 密码
initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能
initParameters.put("allow", ""); // IP白名单 (没有配置或者为空,则允许所有访问)
//initParameters.put("deny", "192.168.20.38");// IP黑名单 (存在共同时,deny优先于allow)
servletRegistrationBean.setInitParameters(initParameters);
return servletRegistrationBean;
}