成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

我的第一個springboot接口項目-創(chuàng)新互聯(lián)

  1. idea創(chuàng)建項目

在這里插入圖片描述
勾選web-spring web依賴
在這里插入圖片描述
創(chuàng)建新的類,拼接url
在這里插入圖片描述
啟動
@SpringBootApplication

東光ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

postman調(diào)用接口http://localhost:8080/h1/h2
在這里插入圖片描述

  1. 帶有參數(shù)的接口
package com.example.demo;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/h1")
public class http {@RequestMapping("/h2")
    public String toweb(@RequestBody Test param){System.out.println(param.getAge()+"&&&");
        System.out.println(param.getName()+"****");
        System.out.println("sucess"+param);
        return "hello";
    }
}

Test是自定義的類,

package com.example.demo;

public class Test {int age;
    String name;

    @Override
    public String toString() {return "Test{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    public void setAge(int age) {this.age = age;
    }

    public void setName(String name) {this.name = name;
    }

    public int getAge() {return age;
    }

    public String getName() {return name;
    }

    public Test(int age, String name) {this.age = age;
        this.name = name;
    }
}

postmen里面的json字段要和類的屬性一致,否則獲取到null,如果不加@RequestBody,則
可以獲取到form-data和x-www-form-urlencoded

@GetMapping("/goods/{id}")
    public Goods goods(@PathVariable(name = "id") Integer id) {Goods g = new Goods(id, "草莓", 6.5, new Date(), "好吃");
        return g;
    }
@RestController
@RequestMapping("/h1")
public class http {@RequestMapping("/h2/{id}")
    @ResponseBody
    public String toweb(@PathVariable(name = "id") Integer id){System.out.println(id+"&&&");
        System.out.println("sucess");
        return "543";
    }
}

在這里插入圖片描述

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧

當(dāng)前題目:我的第一個springboot接口項目-創(chuàng)新互聯(lián)
分享路徑:http://jinyejixie.com/article26/cchpjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化營銷型網(wǎng)站建設(shè)、App開發(fā)

廣告

聲明:本網(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)

綿陽服務(wù)器托管
元阳县| 辽阳县| 苗栗市| 遵化市| 南京市| 旌德县| 定州市| 静海县| 北海市| 南安市| 宣武区| 波密县| 东安县| 南和县| 丹寨县| 茌平县| 香格里拉县| 伊吾县| 开化县| 祥云县| 米脂县| 木兰县| 南康市| 安龙县| 赣榆县| 定陶县| 娄底市| 贵南县| 嘉义县| 沿河| 图们市| 乐至县| 横山县| 霍城县| 武威市| 毕节市| 溆浦县| 高要市| 烟台市| 塘沽区| 莫力|