久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

SpringBoot @RequestParam、@PathVaribale、@RequestBody實戰案例

瀏覽:100日期:2023-04-09 10:05:47

實例User

package com.iflytek.odeon.shipper.model.rx;import io.swagger.annotations.ApiModelProperty;public class Student { @ApiModelProperty(value = '名稱', example = 'zhangsan', required = true) private String name; private Integer call; public Student() { } public Student(String name, Integer call) { this.name = name; this.call = call; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getCall() { return call; } public void setCall(Integer call) { this.call = call; } @Override public String toString() { return 'Student{' +'name=’' + name + ’’’ +', call=' + call +’}’; }}

實例Controller

package com.iflytek.odeon.shipper.controller;import com.iflytek.odeon.shipper.model.rx.Student;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.*;/** * 測試注解及調試功能API */@RestController@RequestMapping('/v1')public class SampleController { @PostMapping('/hi') public Student hi(@RequestBody() Student student) { return new Student(student.getName(), student.getCall()); } @PostMapping('/hello') public Student hello(@RequestParam(value = 'name') String name, @RequestParam(value = 'call') Integer call) { Student stuResponse = new Student(); stuResponse.setName(name + 'call'); stuResponse.setCall(call); return stuResponse; } @GetMapping('/hello/{id}') public Integer getUrl(@PathVariable(value = 'id') Integer id) { return id; }}

效果

body

SpringBoot @RequestParam、@PathVaribale、@RequestBody實戰案例

parme key value

SpringBoot @RequestParam、@PathVaribale、@RequestBody實戰案例

pathvar/{id}

SpringBoot @RequestParam、@PathVaribale、@RequestBody實戰案例

到此這篇關于SpringBoot @RequestParam、@PathVaribale、@RequestBody實戰案例的文章就介紹到這了,更多相關SpringBoot @RequestParam、@PathVaribale、@RequestBody內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 交城县| 江油市| 洛宁县| 杭锦后旗| 漠河县| 淅川县| 桐柏县| 五台县| 德州市| 贵阳市| 景德镇市| 武胜县| 萨迦县| 嘉鱼县| 涟水县| 柘城县| 汽车| 新蔡县| 石屏县| 商城县| 潼南县| 宁海县| 大连市| 曲靖市| 正镶白旗| 建水县| 绿春县| 巴南区| 泸水县| 静乐县| 武宁县| 邵阳市| 什邡市| 涡阳县| 府谷县| 邻水| 宿迁市| 金华市| 迭部县| 佛学| 韩城市|