money字段加上@NotNull之后,通過Postman工具添加girl,報For input string: \"Min\
controller
@PostMapping("/addGirl")
public Result addGirl(@Valid Girl girl, BindingResult bindingResult) {
? ?if (bindingResult.hasErrors()) {
? ? ? ?return ResultUtil.fail(new Integer(bindingResult.getFieldError().getCode()), bindingResult.getFieldError().getDefaultMessage());
? ?}
? ?return ResultUtil.success(girlRepository.save(girl));
}
domain
@Entity
public class Girl {
? ?@Id
? ?@GeneratedValue
? ?private Integer id;
? ?private String cupSize;
? ?@Min(value = 18, message = "不能小于18歲")
? ?private Integer age;
? ?@NotNull(message = "金額必傳")
? ?private Double money;
? ?public Double getMoney() {
? ? ? ?return money;
? ?}
? ?public void setMoney(Double money) {
? ? ? ?this.money = money;
? ?}
? ?public Girl() {
? ?}
? ?public Integer getId() {
? ? ? ?return id;
? ?}
? ?public void setId(Integer id) {
? ? ? ?this.id = id;
? ?}
? ?public String getCupSize() {
? ? ? ?return cupSize;
? ?}
? ?public void setCupSize(String cupSize) {
? ? ? ?this.cupSize = cupSize;
? ?}
? ?public Integer getAge() {
? ? ? ?return age;
? ?}
? ?public void setAge(Integer age) {
? ? ? ?this.age = age;
? ?}
? ?@Override
? ?public String toString() {
? ? ? ?return "Girl{" +
? ? ? ? ? ? ? ?"id=" + id +
? ? ? ? ? ? ? ?", cupSize='" + cupSize + '\'' +
? ? ? ? ? ? ? ?", age=" + age +
? ? ? ? ? ? ? ?", money=" + money +
? ? ? ? ? ? ? ?'}';
? ?}
}
以下是postman請求截圖
為什么報這個錯誤,老鐵幫忙看看
2018-02-03
我也是這個問題? 則呢么請空緩存? 輸入正確的也報錯
2017-11-30
有時候有緩存在里面,導致你的請求沒有發現你修改的內容,很正常,需要過幾秒之后再試試就行了
2017-11-24
后來重新請求了一次又可以了,什么都沒改,發現唯一的區別就是第一次請求的header中多了connection=close,這是為什么?