springboot(1)

一。标签

@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

 

上一篇:67.Python:多态与鸭子类型


下一篇:Java生成文档命令