POST 请求错误,该如何解决
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Created by Administrator on 2017/5/4.
*/
@RestController
public class GirlController {
@Autowired
private GirlRepository girlRepository;
//查询所有的女生列表
@GetMapping(value = "/girl")
public List<Girl> girlList(){
return girlRepository.findAll();
}
//添加一个女生 cupSize age
@PostMapping(value = "/girls")
public Girl girlAdd(@RequestParam("cupSize") String cupSize,
@RequestParam("age") Integer age) {
Girl girl =new Girl();
girl.setCupSize(cupSize);
girl.setAge(age);
return girlRepository.save(girl);
//return girlRepository.save(girl);
}
}