전자정부표준프레임워크/Exception 및 Error
Neither BindingResult nor plain target object for bean name 'command' available as request attribute
yeon.Biju
2022. 7. 7. 16:06
Neither BindingResult nor plain target object for bean name 'command' available as request attribute
내내 잘 쓰던 코드를 가져다가 다른 이클립스에 적용을 해보니 위와 같은 오류가 발생하였다.
ERROR [org.springframework.web.servlet.tags.form.HiddenInputTag] Neither BindingResult nor plain target object for bean name 'command' available as request attribute
조금 더 살펴보니 위와 같이 나와서 <form:hidden path="" /> 가 문제인가 싶어서도 한참 고민하게 되었다.
에러가 난 Controller 의 소스는 아래와 같다.
1
2
3
4
5
6
|
@RequestMapping(value="/aaaaaaa")
public String selectRoleList(@ModelAttribute("searchVO") AaaaVO aaaaVO,
ModelMap model) throws Exception {
return "aaaaaa";
}
|
cs |
JSP 소스는 는 아래와 같다.
1
2
3
4
|
<form:form commandName="searchVO" name="defaultForm">
<form:hidden path="pageIndex" />
<form:hidden path="codeNm" />
</form:form>
|
cs |
일단 command 를 정의한 곳이 없는데.. command 라고 나오니 환장할 노릇이었다.
기존에는 @ModelAttribute("searchVO") 과 commandName="searchVO" 를 맞춰주면 되었는데 오늘은 그렇지 않아서 한참동안 헤매니 환장할 노릇이었다.
이것저것 뒤져본 후에
1
|
<form:form commandName="searchVO" name="defaultForm">
|
cs |
을
1
|
<form:form modelAttribute="searchVO" name="defaultForm">
|
cs |
이것으로 변경해주니 잘 되었다.
commandName 대신에 modelAttribute 를 쓰니 발생하지 않는다.
아마도 스프링 버전에 따라서 차이가 있는 거 아닐까 생각해본다.
기존 환경은 Spring 4.x 이고 새로운 환경은 Spring 5.x 이니 말이다.
다시 말해서 전자정부표준프레임워크 3.9까지는 잘 되었는데, 4.0으로 해보니 동일한 소스지만 오류가 발생하였으니 말이다.