最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot里使用Servlet進(jìn)行請(qǐng)求的實(shí)現(xiàn)示例

 更新時(shí)間:2021年01月12日 14:27:40   作者:天龍至尊  
這篇文章主要介紹了SpringBoot里使用Servlet進(jìn)行請(qǐng)求的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

首先,在main方法的類上添加注解:

@ServletComponentScan(basePackages = "application.servlet")

示例代碼:

package application; 
import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
 
import javax.annotation.Resource;
 
/**
 * @author wtl
 */
@SpringBootApplication
@EnableFeignClients
@EnableCaching
@EnableAutoDataSourceProxy
@MapperScan(basePackages = "application.mybatis.mappers")
@ServletComponentScan(basePackages = "application.servlet")
public class SpringBootMain extends SpringBootServletInitializer {
 
  public static void main(String[] args) {
    SpringApplication.run(SpringBootMain.class,args);
    Application.launch(FxmlRunner.class,args);
  }
 
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(SpringBootMain.class);
  }
}

使用 @WebServlet(name = "DownloadServlet",urlPatterns = "/test") 進(jìn)行使能Servlet:

@WebServlet(name = "DownloadServlet",urlPatterns = "/test")

示例:

package application.servlet;
 
import application.service.BiliBiliIndexService;
import lombok.SneakyThrows;
 
import javax.annotation.Resource;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
 
/**
 * @author: wtl
 * @Date: 2020/7/5
 * @Time: 18:48
 * @Description:
 */
@WebServlet(name = "DownloadServlet",urlPatterns = "/test")
public class DownloadServlet extends HttpServlet {
 
  @Resource
  private BiliBiliIndexService biliBiliIndexService;
 
  @SneakyThrows
  @Override
  protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
    String aid = httpServletRequest.getParameter("aid");
    String cid = httpServletRequest.getParameter("cid");
    biliBiliIndexService.getVideoStream(aid,cid,httpServletRequest,httpServletResponse);
  }
}

到此這篇關(guān)于SpringBoot里使用Servlet進(jìn)行請(qǐng)求的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)SpringBoot Servlet請(qǐng)求內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • @RequestParam?和@RequestBody注解的區(qū)別解析

    @RequestParam?和@RequestBody注解的區(qū)別解析

    在 Spring MVC 中,我們可以使用 @RequestParam 和 @RequestBody 來獲取請(qǐng)求參數(shù),但它們?cè)谟梅ê妥饔蒙嫌幸恍﹨^(qū)別,這篇文章主要介紹了@RequestParam?和@RequestBody注解的區(qū)別,需要的朋友可以參考下
    2023-06-06
  • 擴(kuò)展Hibernate使用自定義數(shù)據(jù)庫連接池的方法

    擴(kuò)展Hibernate使用自定義數(shù)據(jù)庫連接池的方法

    這篇文章主要介紹了擴(kuò)展Hibernate使用自定義數(shù)據(jù)庫連接池的方法,涉及Hibernate數(shù)據(jù)庫操作擴(kuò)展的相關(guān)技巧,需要的朋友可以參考下
    2016-03-03
  • Java中異或的深入講解

    Java中異或的深入講解

    這篇文章主要給大家介紹了關(guān)于Java中異或的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Java具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • springboot實(shí)現(xiàn)修改請(qǐng)求狀態(tài)404改為200

    springboot實(shí)現(xiàn)修改請(qǐng)求狀態(tài)404改為200

    這篇文章主要介紹了springboot實(shí)現(xiàn)修改請(qǐng)求狀態(tài)404改為200方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Spring Controller接收前端JSON數(shù)據(jù)請(qǐng)求方式

    Spring Controller接收前端JSON數(shù)據(jù)請(qǐng)求方式

    這篇文章主要為大家介紹了Spring Controller接收前端JSON數(shù)據(jù)請(qǐng)求方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • JAVA動(dòng)態(tài)維度笛卡爾積輸出的實(shí)現(xiàn)

    JAVA動(dòng)態(tài)維度笛卡爾積輸出的實(shí)現(xiàn)

    本文主要介紹了JAVA動(dòng)態(tài)維度笛卡爾積輸出的實(shí)現(xiàn),通過動(dòng)態(tài)生成笛卡爾積,可以方便地處理多維數(shù)據(jù)集,提高數(shù)據(jù)處理效率,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-02-02
  • Java中RocketMQ使用方法詳解

    Java中RocketMQ使用方法詳解

    這篇文章主要介紹了RocketMQ和Kafka在SpringBoot中的使用方法,以及如何保證消息隊(duì)列的順序性、可靠性以及冪等性,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-02-02
  • Spring?Boot實(shí)現(xiàn)分布式系統(tǒng)中的服務(wù)發(fā)現(xiàn)和注冊(cè)(最新推薦)

    Spring?Boot實(shí)現(xiàn)分布式系統(tǒng)中的服務(wù)發(fā)現(xiàn)和注冊(cè)(最新推薦)

    在本文中,我們深入探討了Spring?Boot如何實(shí)現(xiàn)分布式系統(tǒng)中的服務(wù)發(fā)現(xiàn)和注冊(cè),我們使用Eureka作為服務(wù)注冊(cè)中心,Ribbon作為負(fù)載均衡器,Hystrix作為熔斷器,成功地實(shí)現(xiàn)了服務(wù)發(fā)現(xiàn)、服務(wù)注冊(cè)、負(fù)載均衡和服務(wù)熔斷等功能,需要的朋友參考下吧
    2023-06-06
  • Java數(shù)據(jù)結(jié)構(gòu)之對(duì)象比較詳解

    Java數(shù)據(jù)結(jié)構(gòu)之對(duì)象比較詳解

    這篇文章主要為大家詳細(xì)介紹了Java中對(duì)象的比較、集合框架中PriorityQueue的比較方式以及PriorityQueue的模擬實(shí)現(xiàn),感興趣的可以了解一下
    2022-07-07
  • 關(guān)于java數(shù)組與字符串相互轉(zhuǎn)換的問題

    關(guān)于java數(shù)組與字符串相互轉(zhuǎn)換的問題

    這篇文章主要介紹了java數(shù)組與字符串相互轉(zhuǎn)換的問題,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-10-10

最新評(píng)論

宁晋县| 屏东县| 扶余县| 南康市| 洛浦县| 城口县| 蛟河市| 赤壁市| 中宁县| 会昌县| 喜德县| 军事| 宾川县| 霍邱县| 隆安县| 巴青县| 太湖县| 永新县| 涡阳县| 绥滨县| 右玉县| 凌海市| 临汾市| 铜陵市| 剑阁县| 沅江市| 腾冲县| 石楼县| 墨竹工卡县| 大丰市| 鹤壁市| 科技| 资源县| 旌德县| 巴楚县| 浏阳市| 三明市| 鹤庆县| 牙克石市| 东港市| 永兴县|