当前位置: 首页> 文旅> 艺术 > 哪个平台查企业是免费的_模板app_seo+网站排名_长沙网站seo排名

哪个平台查企业是免费的_模板app_seo+网站排名_长沙网站seo排名

时间:2025/7/12 19:28:31来源:https://blog.csdn.net/isolusion/article/details/144793589 浏览次数:0次
哪个平台查企业是免费的_模板app_seo+网站排名_长沙网站seo排名

一.如何定制和修改Servlet容器的相关配置

修改和server有关的配置(ServerProperties);

server.port=8081

server.context‐path=/tx

server.tomcat.uri‐encoding=UTF‐8

在yml配置文件的写法:

server:port: 8081servlet:context-path: /tx

二.注册Servlet三大组件【Servlet、Filter、Listener】

由于SpringBoot默认是以jar包的方式启动嵌入式的Servlet容器来启动SpringBootweb应用,没有web.xml文件。

1.servlet

//注册三大组件

@Bean

public ServletRegistrationBean myServlet(){

ServletRegistrationBean registrationBean = new ServletRegistrationBean(new

MyServlet(),"/myServlet");

return registrationBean;

}

2.FilterRegistrationBean

@Bean

public FilterRegistrationBean myFilter(){

FilterRegistrationBean registrationBean = new FilterRegistrationBean();

registrationBean.setFilter(new MyFilter());

registrationBean.setUrlPatterns(Arrays.asList("/hello","/myServlet"));

return registrationBean;

}

3.ServletListenerRegistrationBean

@Bean

public ServletListenerRegistrationBean myListener(){

ServletListenerRegistrationBean<MyListener> registrationBean = new

ServletListenerRegistrationBean<>(new MyListener());

return registrationBean;

}

SpringBoot帮我们自动SpringMVC的时候,自动的注册SpringMVC的前端控制器;DispatcherServlet

DispatcherServletAutoConfiguration中:

@Bean(name = DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)

@ConditionalOnBean(value = DispatcherServlet.class, name =

DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)

public ServletRegistrationBean dispatcherServletRegistration(

DispatcherServlet dispatcherServlet) {

ServletRegistrationBean registration = new ServletRegistrationBean(

dispatcherServlet, this.serverProperties.getServletMapping());

//默认拦截: / 所有请求;包静态资源,但是不拦截jsp请求; /*会拦截jsp

//可以通过server.servletPath来修改SpringMVC前端控制器默认拦截的请求路径

registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);

registration.setLoadOnStartup(

this.webMvcProperties.getServlet().getLoadOnStartup());

if (this.multipartConfig != null) {

registration.setMultipartConfig(this.multipartConfig);

}

return registration;

}

关键字:哪个平台查企业是免费的_模板app_seo+网站排名_长沙网站seo排名

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: