I have a requirement in which CRUD operations need to be exposed through REST web services with Spring and Hibernate. Presentation is through JSF. It would be of great help if I can get a sample code for this.
@Controller
@RequestMapping("/foo")
public class FooController {
@Inject private FooService service;
@RequestMapping("/create", method=RequestMethod.PUT)
public void create(@Valid Foo foo) { .. }
@RequestMapping("/retrieve", method=RequestMethod.GET)
public String retrieve(@RequestParam String fooId { .. }
//etc for POST and DELETE
}
(Sometimes people tend to skip the request method limitation, but it feels more RESTful that way)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.