< 에러 메시지 >
SEVERE: 경로 [/13]의 컨텍스트 내의 서블릿 [pf]을(를) 위한 Servlet.service() 호출이, 근본 원인(root cause)과 함께, 예외 [Request processing failed; nested exception is java.lang.IllegalArgumentException: Unknown return value type: java.lang.Integer]을(를) 발생시켰습니다.
java.lang.IllegalArgumentException: Unknown return value type: java.lang.Integer
IllegalArgumentException
메서드에서 전달된 인수가 잘못된 경우 발생하는 예외
< 원인 >
Spring MVC가 int 반환 타입을 처리하지 못해서 발생한 문제
@RequestMapping("/forum/deleteAttachInfo.do")
public int deleteAttachInfo(@RequestParam("attachSeq") int attachSeq) {
return service.deleteAttachInfo(attachSeq);
}
< 해결 >
return타입을 ModelAndView로 변경하여 작성하는 것으로 변경하여 해결
@RequestMapping("/forum/deleteAttachInfo.do")
@ResponseBody
public ModelAndView deleteAttachInfo(@RequestParam("attachSeq") int attachSeq) {
int result = service.deleteAttachInfo(attachSeq);
ModelAndView mv = new ModelAndView();
mv.addObject("result", result);
if (result == 1) {
//-------------------------추가 사항 끝
mv.addObject("code","0000");
mv.addObject("msg", "삭제 완료");
}else {
mv.addObject("code","9000");
mv.addObject("msg", "삭제 실패");
}
mv.setViewName("forum/notice/read");
return mv;
}
'에러 모음' 카테고리의 다른 글
[java]JasperException (0) | 2024.05.17 |
---|---|
NullPointerException (0) | 2024.05.17 |
IncorrectResultSizeDataAccessException (0) | 2024.05.15 |
PropertyNotFoundException (0) | 2024.05.11 |
UnsatisfiedDependencyException, BeanCreationException, IllegalArgumentException (0) | 2024.05.10 |