标签:
public ResponseEntity<String> ordersBack( @PathVariable String reqKey, @RequestParam(value="intVal") Integer intVal, @RequestParam(value="strVal") String strVal) throws Exception{ return new ResponseEntity("ok", HttpStatus.OK); }
@Controller @RequestMapping("/pets") @SessionAttributes("pet") publicclass EditPetForm { @RequestMapping(method = RequestMethod.GET) public String setupForm(@RequestParam("petId") int petId, ModelMap model) { Pet pet = this.clinic.loadPet(petId); model.addAttribute("pet", pet); return"petForm"; } }
@Controller public class PersonController { /** * 查询个人信息 * * @param id * @return */ @RequestMapping(value = "/person/profile/{id}/{name}/{status}", method = RequestMethod.GET) public @ResponseBody Person porfile(@PathVariable int id, @PathVariable String name, @PathVariable boolean status) { return new Person(id, name, status); } /** * 登录 * * @param person * @return */ @RequestMapping(value = "/person/login", method = RequestMethod.POST) public @ResponseBody Person login(@RequestBody Person person) { return person; } }
SpringMVC使用@PathVariable,@RequestBody,@ResponseBody,@RequestParam
标签:
原文地址:http://www.cnblogs.com/lcngu/p/5734307.html