# 为Spring boot项目增加Servlet

## 方式1

Just add a bean for the servlet. It’ll get mapped to /{beanName}/.

Note that if you actually want it mapped to /something/* rather than /something/ you will need to use ServletRegistrationBean

## 方式4

Annotation used to declare a servlet.

This annotation is processed by the container at deployment time, and the corresponding servlet made available at the specified URL patterns.

Please note that @ServletComponentScan will work only with embedded server:

Enables scanning for Servlet components (filters, servlets, and listeners). Scanning is only performed when using an embedded web server.

##参考资料

# Spring RestTemplate parse gzip response

Update your browser to view this website correctly. Update my browser now

×