本文整理匯總了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;
}