本文整理汇总了Java中org.springframework.boot.web.servlet.ServletRegistrationBean.addInitParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRegistrationBean.addInitParameter方法的具体用法?Java ServletRegistrationBean.addInitParameter怎么用?Java ServletRegistrationBean.addInitParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.web.servlet.ServletRegistrationBean
的用法示例。
在下文中一共展示了ServletRegistrationBean.addInitParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registrationBean
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
/**
* 注册ServletRegistrationBean
* @return
*/
@Bean
public ServletRegistrationBean registrationBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
/** 初始化参数配置,initParams**/
//白名单
bean.addInitParameter("allow", "127.0.0.1");
//IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
bean.addInitParameter("deny", "192.168.1.73");
//登录查看信息的账号密码.
bean.addInitParameter("loginUsername", "admin");
bean.addInitParameter("loginPassword", "admin");
//是否能够重置数据.
bean.addInitParameter("resetEnable", "false");
return bean;
}
示例2: servletRegistrationBean
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
/**
* Druid 提供了一个 StatViewServlet 用于展示 Druid 的统计信息
* 这个 StatViewServlet 的用途包括:
* 1. 提供监控信息展示的 HTML 页面
* 2. 提供监控信息的 JSON API
*/
@Bean
public ServletRegistrationBean servletRegistrationBean(DruidDataSourceProperties druidDataSourceProperties) {
log.debug("druid stat-view-servlet init...");
DruidStatViewServletProperties properties = druidDataSourceProperties.getStatViewServlet();
ServletRegistrationBean registration = new ServletRegistrationBean();
StatViewServlet statViewServlet = new StatViewServlet();
registration.setServlet(statViewServlet);
registration.addUrlMappings(properties.getUrlMappings());
if (!StringUtils.isEmpty(properties.getLoginUsername())) {
registration.addInitParameter("loginUsername", properties.getLoginUsername());
}
if (!StringUtils.isEmpty(properties.getLoginPassword())) {
registration.addInitParameter("loginPassword", properties.getLoginPassword());
}
if (!StringUtils.isEmpty(properties.getAllow())) {
registration.addInitParameter("allow", properties.getAllow());
}
if (!StringUtils.isEmpty(properties.getDeny())) {
registration.addInitParameter("deny", properties.getDeny());
}
registration.addInitParameter("resetEnable", Boolean.toString(properties.isResetEnable()));
return registration;
}
示例3: jerseyServletRegistration
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean jerseyServletRegistration(
JerseyProperties jerseyProperties, ResourceConfig config) {
ServletRegistrationBean registration = new ServletRegistrationBean(
new ServletContainer(config));
for (Map.Entry<String, String> entry : jerseyProperties.getInit().entrySet()) {
registration.addInitParameter(entry.getKey(), entry.getValue());
}
registration.addUrlMappings("/" +
(StringUtils.isEmpty(lyreProperties.getApplicationPath()) ? "api" : lyreProperties.getApplicationPath())
+ "/*");
registration.setName(APIx.class.getName());
registration.setLoadOnStartup(1);
return registration;
}
示例4: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
@ConfigurationProperties(DruidServletProperties.DRUID_SERVLET_PREFIX)
public ServletRegistrationBean druidServlet(DruidServletProperties properties) {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings(properties.getUrlMappings());
if(properties.getAllow() !=null){
reg.addInitParameter("allow", properties.getAllow()); // IP白名单 (没有配置或者为空,则允许所有访问)
}
if(properties.getDeny() !=null){
reg.addInitParameter("deny", properties.getDeny()); //IP黑名单 (存在共同时,deny优先于allow)
}
if(properties.getLoginUsername() !=null){
reg.addInitParameter("loginUsername", properties.getLoginUsername()); //用户名
}
if(properties.getLoginPassword() !=null){
reg.addInitParameter("loginPassword", properties.getLoginPassword()); // 密码
}
if(properties.getResetEnable() !=null){
reg.addInitParameter("resetEnable", properties.getResetEnable().toString());// 禁用HTML页面上的“Reset All”功能
}
return reg;
}
示例5: druidStatViewServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
/**
* 数据源监控注册一个StatViewServlet
*
* @return
*/
@Bean
public ServletRegistrationBean druidStatViewServlet(){
//注册监控地址
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//白名单
servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
servletRegistrationBean.addInitParameter("deny","192.168.1.73");
//登录查看信息的账号密码.
servletRegistrationBean.addInitParameter("loginUsername","admin");
servletRegistrationBean.addInitParameter("loginPassword","123456");
//是否能够重置数据.
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例6: messageDispatcherServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean messageDispatcherServlet(
ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
ServletRegistrationBean registration = new ServletRegistrationBean(servlet,
urlMapping);
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
for (Map.Entry<String, String> entry : servletProperties.getInit().entrySet()) {
registration.addInitParameter(entry.getKey(), entry.getValue());
}
return registration;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:WebServicesAutoConfiguration.java
示例7: keycloakJaxRsApplication
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
ServletRegistrationBean keycloakJaxRsApplication(KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception {
mockJndiEnvironment(dataSource);
//FIXME: hack to propagate Spring Boot Properties to Keycloak Application
EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties;
ServletRegistrationBean servlet = new ServletRegistrationBean(new HttpServlet30Dispatcher());
servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName());
servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath());
servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true");
servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*");
servlet.setLoadOnStartup(1);
servlet.setAsyncSupported(true);
return servlet;
}
开发者ID:thomasdarimont,项目名称:spring-boot-keycloak-server-example,代码行数:19,代码来源:EmbeddedKeycloakConfig.java
示例8: statViewServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean statViewServlet(){
//创建servlet注册实体
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//设置ip白名单
// servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//设置ip黑名单,如果allow与deny共同存在时,deny优先于allow
// servletRegistrationBean.addInitParameter("deny","192.168.0.19");
//设置控制台管理用户
servletRegistrationBean.addInitParameter("loginUsername","lpj");
servletRegistrationBean.addInitParameter("loginPassword","123");
//是否可以重置数据
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例9: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("allow", "127.0.0.1");//允许访问地址,不填则全允许,填了只允许
// reg.addInitParameter("deny", "127.0.0.1");
reg.addInitParameter("loginUsername", dbConfigProperties.getDruidVisitName());
reg.addInitParameter("loginPassword", dbConfigProperties.getDruidVisitPwd());
return reg;
}
示例10: statViewServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean statViewServlet(){
//创建servlet注册实体
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
//设置ip白名单
servletRegistrationBean.addInitParameter("allow","127.0.0.1");
//设置ip黑名单,如果allow与deny共同存在时,deny优先于allow
servletRegistrationBean.addInitParameter("deny","192.168.0.19");
//设置控制台管理用户
servletRegistrationBean.addInitParameter("loginUsername","druid");
servletRegistrationBean.addInitParameter("loginPassword","123456");
//是否可以重置数据
servletRegistrationBean.addInitParameter("resetEnable","false");
return servletRegistrationBean;
}
示例11: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("loginUsername", "admin");
reg.addInitParameter("loginPassword", "admin123");
return reg;
}
示例12: servletRegistrationBean
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean servletRegistrationBean() {
logger.info("Registering Errai Servlet");
ServletRegistrationBean registration = new ServletRegistrationBean(new DefaultBlockingServlet(), "*.erraiBus");
registration.addInitParameter("auto-discover-services", "false");
registration.setLoadOnStartup(1);
return registration;
}
示例13: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
logger.info("init Druid Servlet Configuration ");
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// IP白名单
servletRegistrationBean.addInitParameter("allow", "");
// IP黑名单(共同存在时,deny优先于allow)
// servletRegistrationBean.addInitParameter("deny", "");
//控制台管理用户
servletRegistrationBean.addInitParameter("loginUsername", "admin");
servletRegistrationBean.addInitParameter("loginPassword", "admin");
//是否能够重置数据 禁用HTML页面上的“Reset All”功能
servletRegistrationBean.addInitParameter("resetEnable", "false");
return servletRegistrationBean;
}
示例14: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
// servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
// servletRegistrationBean.addInitParameter("deny", "");
servletRegistrationBean.addInitParameter("username", "admin");
servletRegistrationBean.addInitParameter("password", "123456");
return servletRegistrationBean;
}
示例15: druidServlet
import org.springframework.boot.web.servlet.ServletRegistrationBean; //导入方法依赖的package包/类
@Bean
public ServletRegistrationBean druidServlet() {
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/druid/*");
reg.addInitParameter("loginUsername", "admin");
reg.addInitParameter("loginPassword", "admin");
reg.addInitParameter("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能
//reg.addInitParameter("allow", "127.0.0.1");// IP白名单 (没有配置或者为空,则允许所有访问)
//reg.addInitParameter("deny","");// IP黑名单 (存在共同时,deny优先于allow)
return reg;
}