@RequestMapping : URL 매핑
@RequestParam : request 에서 특정 파라미터 값을 찾아냄
@ModelAttribute : 해당객체를 뷰까지 전달
ex ) @RequestMapping("doc")
public String getA(@ModelAttribute("msg") String msg){
return "result";
}
jsp : <span>${msg}</span>
* redirect 해야 할경우
ex)public String getA(RedirectAttributes rttr){
rttr.addAttribute("page", 1); //url 에 쿼리가 붙는다.
rttr.addFlashAttribute("msg","hello"); //url 에 쿼리가 안붙는다.
return "redirect:/getB";
}
@ResponseBody : JSON 데이타 생성
ex) public @ResponseBody productVO getProduct(){
ProductVO vo = new ProductVO();
return vo;
}
@RequestBody : 전송된 jSON 데이타를 객체로 변환해 준다. @ModelAttribute 와 유사하지만 JSON 에서 사용된다.
*return ResponseEntity : 400 상태코드 + 데이타
@PathVariable : 현재 URI 에서 원하는 정보를 추출할때 사용
ex) @RequestMapping(value="/all/{bno}", method=RequestMethod.GET)
public ResponseEntity<List<ReplyVO>> list (@PathVariable("bno") Integer bno){
}
@Requestmapping() 을 보면 URI 내의 경로 {bno}를 활용한다. {bno}는 메소드의 파라미터에서 @PathVariable("bno")로 활용된다.
'Java' 카테고리의 다른 글
SYNCHRONIZE 작업시 불필요한 파일 제외하기 (0) | 2017.07.02 |
---|---|
svn 싱크 (0) | 2017.07.02 |
was 없이 컨트롤러 테스트 하기 (0) | 2017.05.04 |
cross domain (0) | 2012.01.18 |
맥에서 톰캣부팅시키기 (1) | 2012.01.05 |