2012-09-25

Spring MVC Controller 의 REST scaffold

spring roo 가 제공하는 것을 약간 수정하여 나만의 scaffold로...
* roo는 update 경로가 좀 다르고
* list에서 spring data의 Pageable을 사용함.

http://java.dzone.com/articles/restful-standard-resolved 도 참고하자.


@RequestMapping
public String list(@PageableDefaults(pageNumber = 0, value = Config.PAGE_SIZE) Pageable pageable, Model model) {
}

@RequestMapping(method = RequestMethod.POST)
public String create(@Valid MyObj obj, BindingResult bindingResult, Model model, HttpServletRequest httpServletRequest) {
}

@RequestMapping(params = "form")
public String createForm(Model model) {
}

@RequestMapping(value = "/{obj}", method = RequestMethod.PUT)
public String update(@Valid @ModelAttribute("obj") MyObj obj, BindingResult bindingResult, Model model, HttpServletRequest httpServletRequest) {
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public View remove(@PathVariable Long id) {
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ModelAndView show(@PathVariable Long id, Model model) throws Exception {
}

댓글 없음:

댓글 쓰기