반응형
1. 일반 통신 : return시 호출할 페이지입력, Model에 결과 값을 담아서 JSP에 받음, parameter 어노테이션이 @RequestParam임
@RequestMapping(value = "xxxx.do" )
public String name(@RequestParam Map<String, Object> param, Model map) throws Exception {
map.addAttribute( "param1", commercialService .getParam1());
map.addAttribute( "param2", commercialService.getParam2());
return "xxxxx" ;
}
2. Ajax 통신 : return시 값을 바로 던짐,
Ajax 통신 success : javascript에서 result로 받음,
parameter 어노테이션이 @RequestBody 임, @ResponseBody어노테이션으로 JSON형태로 받음
@RequestMapping(value = "xxxx.do" )
public @ResponseBody List<AdongVO> xxxx(@RequestBody SggVO sggVO) throws Exception {
return commercialService .getAdongList(sggVO);
}
3. Ajax 통신 예제 2
@RequestMapping(value = "xxxxx.do" )
public @ResponseBody Map<String, Object> xxx(@RequestBody ResidentVO residentVO){
Map<String, Object> result = new HashMap<String, Object>();
result.put( "list",commercialService .commercialResult(residentVO));
if(residentVO.getBizCd().size() > 0 ){
result.put( "biz",commercialService .getBizPoint(residentVO));
}
return result;
}
반응형
'개발의 흔적 > JAVA' 카테고리의 다른 글
[오류] Current request is not of type [org.springframework.web.multipart.MultipartHttpServletRequest] (0) | 2018.05.31 |
---|---|
야후 환율 API 예제 (0) | 2018.05.30 |
java, eclipse 환경설정 (0) | 2016.01.22 |
자바 용어 정리 (0) | 2016.01.20 |
자바란 무엇인가 (0) | 2016.01.20 |