Questions tagged «spring-4»

4
当对Spring RESTful应用程序使用ResponseEntity <T>和@RestController时
我正在使用Spring Framework 4.0.7,MVC和Rest 我可以和以下人一起安心工作: @Controller ResponseEntity&lt;T&gt; 例如: @Controller @RequestMapping("/person") @Profile("responseentity") public class PersonRestResponseEntityController { 用的方法(只是创建) @RequestMapping(value="/", method=RequestMethod.POST) public ResponseEntity&lt;Void&gt; createPerson(@RequestBody Person person, UriComponentsBuilder ucb){ logger.info("PersonRestResponseEntityController - createPerson"); if(person==null) logger.error("person is null!!!"); else logger.info("{}", person.toString()); personMapRepository.savePerson(person); HttpHeaders headers = new HttpHeaders(); headers.add("1", "uno"); //http://localhost:8080/spring-utility/person/1 headers.setLocation(ucb.path("/person/{id}").buildAndExpand(person.getId()).toUri()); return new ResponseEntity&lt;&gt;(headers, HttpStatus.CREATED); } 退还一些东西 …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.