Reputation: 1
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.
Upvotes: 0
Views: 1359
Reputation: 597016
@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)
Upvotes: 2