Spring Form 과 일반 Form 사용시 에러
Field error in object 'Vo' on field '변수명': rejected value []; codes [typeMismatch.Vo.suvMngNum,typeMismatch.suvMngNum,typeMismatch.long,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [Vo.suvMngNum,suvMngNum]; arguments []; default message [suvMngNum]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'long' for property 'suvMngNum'; nested exception is java.lang.NumberFormatException: For input string: ""]
[원인]
하나의 jsp 안에 Spring- form 태그 와 일반 form태그를 같이 사용하여 발생한 문제 였음.
Spring fom인 <form:form>사용시에는 input도 <form:input 형식으로 사용([O]과 같이) 해야 하는데 ([X]와 같이)위와 같이 사용했기 때문에 null 오류가 발생 하였음
ex)
<form:form name="listFormList" commandName="Vo" method="post" id="listFormList"
aciton="/service/ej/testBoardList.do">
[X] <input type="hidden" name="suvMngNum" value="" />
[O] <form:hidden path="suvMngNum" value="" />
▶ 일반 form
<form name="listFormList" name="EjVo" method="post" id="listFormList"
aciton="/service/ej/testBoardList.do">
<input type="hidden" name="suvMngNum" value="" />
- Request로 들어옴
▶Spring form
<form:form name="listFormList" commandName="Vo" method="post" id="listFormList"
aciton="/service/ej/testBoardList.do">
<form:input path="searchKeyword" value="" />
- VO로 들어옴
출처: https://programming-notes.tistory.com/