小编这次要给大家分享的是SpringBoot如何注入servlet,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。问:有了springMVC,为什么还要用servlet?有了servlet3的注解,为什
小编这次要给大家分享的是SpringBoot如何注入servlet,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。
问:有了springMVC,为什么还要用servlet?有了servlet3的注解,为什么还要使用ServletReGIStrationBean注入的方式?
使用场景:在有些场景下,比如我们要使用hystrix-dashboard,这时候就需要注入HystrixMetriCSStreamServlet(第三方的servlet),该servlet是hystrix的组件。
一、代码
TestServlet(第一个servlet)
package com.xxx.secondboot.servlet;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.Http.httpservlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class TestServlet extends HttpServlet { private static final long serialVersionUID = -4619665430596950563L; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("zhaojigang servlet"); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { this.doGet(req, resp); }}
--结束END--
本文标题: springboot如何注入servlet
本文链接: https://www.lsjlt.com/news/226436.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0