*.JAVA
----------------------------------------------------------------------------------------------
@ResponseBody
public String selectSubMenu(HttpServletResponse response) throws Exception {
MenuSearchVO searchVO = new MenuSearchVO();
LoginVO userVO = EgovUserDetailsHelper.isAuthenticated() ? (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser() : null;
if (userVO != null) {
searchVO.setEmplyrId(userVO.getId());
}
List<MenuSearchVO> list = menuService.selectSubMenuList(searchVO);
JSONArray jsonArray = new JSONArray();
response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/html;charset=utf-8");
for( int i=0; i<list.size(); i++ ){
JSONObject obj = new JSONObject();
MenuSearchVO rvo = (MenuSearchVO)list.get(i);
// AJAX UTF - 8
String menuNm = URLEncoder.encode(rvo.getMenuNm(), "utf-8");
obj.put("menuNo", rvo.getMenuNo());
obj.put("menuNm", menuNm);
obj.put("authorCode", rvo.getAuthorCode());
obj.put("upperMenuNo", rvo.getUpperMenuNo());
jsonArray.add(obj);
}
System.out.println(jsonArray);
return JSONValue.toJSONString(jsonArray);
}
*.JS
----------------------------------------------------------------------------------------------
$.post(url, v, function(data){
$.each(data, function(i, v){
var menuName = decodeURIComponent(v.menuNm);
});
});