开发者

REST web services with Spring and Hibernate

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 gr开发者_StackOverfloweat 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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜