通過springboot寫post請求

使用工具類

     <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.3.2</version>
        </dependency>

編寫請求類

@Controller
public class UploadController {

    @RequestMapping("/{page}")
    public String showPage(@PathVariable String page) {
        return page;
    }

    @GetMapping("/posthttp")
    public String postparam(String param,Model model) {
        if (param.equals("")) {
            Person single = new Person("aa", 11);
            model.addAttribute("singlePerson", single);
            model.addAttribute("postcontent", "URL沒有數(shù)據(jù)");
            return "person";
        } else {
            Person single = new Person("aa", 11);
            model.addAttribute("singlePerson", single);
//        System.out.println("這是提交的參數(shù):"+param);
            HttpRequest httpRequest = HttpRequest.get(param);
            HttpResponse execute = httpRequest.execute();
//        System.out.println("這是結(jié)果"+execute.body());
            model.addAttribute("postcontent", execute.toString());
            return "person";
        }

響應

通過springboot寫post請求

成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供昂昂溪網(wǎng)站建設、昂昂溪做網(wǎng)站、昂昂溪網(wǎng)站設計、昂昂溪網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、昂昂溪企業(yè)網(wǎng)站模板建站服務,十余年昂昂溪做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

通過springboot寫post請求

名稱欄目:通過springboot寫post請求
文章位置:http://www.muchs.cn/article24/jsooje.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、網(wǎng)站導航、網(wǎng)站改版關(guān)鍵詞優(yōu)化、營銷型網(wǎng)站建設、域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)