首页 > 编程语言 > 详细

springboot(1)

时间:2020-03-01 18:34:57      阅读:59      评论:0      收藏:0      [点我收藏+]

一。标签

@PathVariable:获取url中的参数 例如:http://localhost:8090/girl/say/1 

@RequestMapping(value="/say/{id}", method=RequestMethod.GET)
    public String say(@PathVariable(value = "id") Integer id) {
        return "id:"+id;
    }

@RequestParam: 获取http://localhost:8090/girl/say?id=1

@Value : 读取application.yml中的配置项

@ConfigurationProperties:从application.yml中的配置项封装到类

@Component
@ConfigurationProperties(prefix = "girl")
public class Girl {
    private String cupSize;
    private String age;
    public String getCupSize() {
        return cupSize;
    }
    public void setCupSize(String cupSize) {
        this.cupSize = cupSize;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
}
girl:
  cupSize: F
  age: 20

 

springboot(1)

原文:https://www.cnblogs.com/t96fxi/p/12390969.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!