-- Controller --
@RequestMapping(path = "/selectUserAuthItem", method = RequestMethod.POST, produces = "application/json; charset=utf8")
public String selectUserAuthItem(HttpServletRequest request, HttpServletResponse response, Model model, MenuVo menuVo, Locale locale) {
HttpSession session = request.getSession();
LoginVo loginVo = (LoginVo) session.getAttribute("login");
Gson gson = new Gson();
String resultMsg = null;
Map<String, Object> paramMap = new HashMap<String, Object>();
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String, Object> MenuList = new HashMap<String, Object>();
Map<String, Object> CategoryList = new HashMap<String, Object>();
Map<String, Object> MemberList = new HashMap<String, Object>();
try {
System.out.println(">>>>>> START: ");
MenuList = authService.selectMenu();
CategoryList = authService.selectCategory();
MemberList = authService.selectMember();
resultMap.putAll(MenuList);
resultMap.putAll(CategoryList);
resultMap.putAll(MemberList);
System.out.println(">>>>>> resultMap: " + resultMap.toString());
System.out.println(">>>>>> END: ");
resultMsg = messageSource.getMessage(Constants.RESULT_LOGIN_OK_MSG_CD, null, locale);
resultMap.put("resultMsg", resultMsg);
resultMap.put("resultCd", Constants.RESULT_LOGIN_OK_CD);
} catch (Exception e) {
e.printStackTrace();
resultMsg = messageSource.getMessage("login.msg.error", null, locale);
resultMap.put("resultMsg", resultMsg);
resultMap.put("resultCd", Constants.RESULT_LOGIN_ERROR_CD);
logger.error("{} : {}", Thread.currentThread().getStackTrace()[1].getMethodName(), e.getMessage());
}
return gson.toJson(resultMap);
}
-- userAuthForm의 ajax 구문--
function selectUserAuthItem(gridName) {
var itemUrl = "/selectUserAuthItem";
var itemData = {"gridName": gridName};
$.ajax({
url: itemUrl,
type: 'post',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(itemData),
success:function(result) {
console.log(result);
}
})
}
-- javaScript 구문--
selectUserAuthItem("User");
Controller에서 던져준 resultMap값을 받아서 ajax 함수를 통해 Grid에 데이터를 뿌려주는 코드를 작업하고 있습니다. 함수에 던져준값이 User면 User 데이터를 가지고 와서 뿌리고, Menu면 Menu 데이터를 뿌리게 만들었습니다. 일단 Ajax 구문에 익숙하지가 않아서 간단하게 작성해보았는데, 계속
Cannot forward to error page for request [/selectUserAuthItem] as the response has already been committed.
이런 오류가 발생하고 있습니다. Ajax 구문을 잘못써서 발생하는 오류인것 같은데 재가 어디서 잘못 작성한 걸까요?