728x90
1. pom.xml 설정(Maven 설정)
<!-- Ajax jQuery -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib-ext-spring</artifactId>
<version>1.0.2</version>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
2. dispatcher-servlet.xml 설정
<bean id="jsonView" class="net.sf.json.spring.web.servlet.view.JsonView">
<property name="contentType" value="application/json;charset=UTF-8" />
</bean>
3. Controller 설정
@RequestMapping(value = "/biz/mkform/mkFormListJson.do")
public ModelAndView selectMkFormListJson(CommandMap commandMap) throws Exception {
ModelAndView mav = new ModelAndView("jsonView");
Map<String,Object> resultMap = mkFormService.selectUserTableList(commandMap.getMap());
mav.addObject("resultMap", resultMap);
return mav;
}
4.jsp설정
jQuery.ajax({
type:'POST',
url:'/biz/mkform/mkFormListJson.do',
data:'',
async:false,
dataType:'json',
success:function(data){
document.getElementById("wow").innerHTML = data.resultMap;
},
error:function(request,status,error){
alert('[' + request.status + '] 에러가 발생하였습니다.');
}
});
728x90
'STUDY > SpringLegacy' 카테고리의 다른 글
[STS] 프로젝트 빨간 엑스 x 표시 해결방법 (maven) (0) | 2024.04.22 |
---|---|
[Spring] Multipart 파일 업로드 총정리 (0) | 2024.02.21 |
[Spring] 한글 깨짐 해결 방법 (0) | 2023.07.25 |
[Spring] egovMap (0) | 2023.05.24 |
[Spring] @Resource (0) | 2023.05.24 |