Failed to convert value of type 'java.util.LinkedHashMap' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.util.LinkedHashMap' to required type 'java.lang.String': no matching editors or conversion strategy found
게시글 수정 페이지에서 파일 업로드 제한 기능을 구현하는 도중 다음과 같은 에러가 발생했다.결론부터 말하면 RedirectAttributes를 사용해서게시글 수정 기능을 하는 updateBoard.do에서 게시글 수정 jsp로 이동하는 updatePage.do로 params를 전달할 때 문제가 발생한 것이었다.
단순하게 HashMap<String, String> params를 동일하게 사용하기에그대로 전달하면 될 줄 알았는데 params가 복합 객체이기 때문에 에러가 발생하던 것이었다!
따라서
// 기존
redirectAttributes.addAttribute("params", params);
// 변경 후
redirectAttributes.addAttribute("boardTypeSeq", boardTypeSeq);
redirectAttributes.addAttribute("boardSeq", boardSeq);
redirectAttributes.addAttribute("memberId", memberId);
위와 같이 필요한 파라미터를 개별적으로 전달하여 문제를 해결할 수 있었다!
파라미터 전달 시 자료형에 유의하자!!!!!!!!!!
프로젝트에서 여러 파라미터를 한 번에 전달할 수 있는
HashMap<String, String>을 사용하면 편리하지만,
복합 객체의 경우에는 예상치 못한 에러가 발생할 수 있었다.
따라서, 특정 파라미터가 필요한 경우에는
개별적으로 전달하는 것이 더 안전하고 확실한 방법이라는 점을 알게 되었다!
| GitHub 연동 오류 (0) | 2024.11.24 |
|---|---|
| [에러]Invalid value type for attribute 'factoryBeanObjectType': java.lang.String (1) | 2024.11.19 |
| 413 Request Entity Too Large - Nginx (0) | 2024.10.26 |
| contact.do로 제대로 이동하지 않았던 이유 (0) | 2024.06.07 |
| 필터가 두 번 호출된 이유 (1) | 2024.06.05 |