- 在springboot项目中重写了一个servlet并且配置
server:
port: 8132
servlet:
context-path: /aaa
@Bean
public ServletRegistrationBean commonServlet() {
if (log.isDebugEnabled()) {
log.debug("开始初始化common servlet");
}
ServletRegistrationBean servletServletRegistrationBean = new ServletRegistrationBean();
servletServletRegistrationBean.setServlet(new ResourceServlet("/support/"));
Map<String, String> initParams = new HashMap<>(10);
HfViewConfig bean = context.getBean(HfViewConfig.class);
if (bean != null && !bean.equals(new HfViewConfig())) {
initParams.put(PARAM_NAME_USERNAME, bean.getLogin());
initParams.put(PARAM_NAME_PASSWORD, bean.getPassword());
}
servletServletRegistrationBean.addUrlMappings(new String[]{"/common/*"});
servletServletRegistrationBean.setInitParameters(initParams);
if (log.isDebugEnabled()) {
log.debug("开始初始化common servlet 完成.");
}
return servletServletRegistrationBean;
}
<link href="css/demo.css" rel="stylesheet">
<script src="js/a.js"></script>
在druid中有下面图中文件
采用的读取方式即: 读取html文件本身,其html在浏览器中
它的url会被带有
相关druid配置代码
@Bean
public ServletRegistrationBean statViewServlet() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/drc/*");
Map<String, String> initParams = new HashMap<>();
initParams.put("loginUsername", "admin"); //设置登陆账号密码
initParams.put("loginPassword", "123456");
initParams.put("allow", "");
bean.setInitParameters(initParams);
return bean;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…