2012-10-15 2 views
0

국가, 주 및 도시 드롭 다운 상자가있는 JSP가 있습니다. 기본적으로 도시에 인구가 채워진 다음 아약스를 사용하여 선택한 국가와 주에 따라 주와 도시가 나옵니다. 내가이 양식을 제출하면선택 상자 제출시 봄 mvc 바인딩 예외

<form:select path="ContactInfoVO[0].countryList" multiple="single" id="country">  
<form:option value="-1" label="-- Select Country--"></form:option>      
<c:forEach var="country" items="${ManagerVO.ContactInfoVO[0].countryList}" varStatus="item"> 
<form:option value="${country.countryId}" label="${country.countryName}"/></c:forEach> </form:select> 

<form:select path="ContactInfoVO[0].stateList" multiple="single" id="state" class="small">  
<form:option value="-1" label="-- Select State--"></form:option>       
<c:forEach var="state" items="${ManagerVO.ContactInfoVO[0].stateList}" varStatus="item"> 
<form:option value="${state.stateId}" label="${state.stateName}"/></c:forEach></form:select>  

<form:select path="ContactInfoVO[0].cityList" multiple="single" id="city" class="validate[required] small">  
<form:option value="-1" label="-- Select City--"></form:option>      
<c:forEach var="city" items="${ManagerVO.ContactInfoVO[0].cityList}" varStatus="item"> 
<form:option value="${city.cityId}" label="${city.cityName}"/></c:forEach></form:select> 

, 내가 무엇입니까 오류 -

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors 
    Field error in object 'ManagerVO' on field 'ContactInfoVO[0].cityList': rejected value [80930]; codes [typeMismatch.ManagerVO.ContactInfoVO[0].cityList,typeMismatch.ManagerVO.ContactInfoVO.cityList,typeMismatch.ContactInfoVO[0].cityList,typeMismatch.ContactInfoVO.cityList,typeMismatch.cityList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [ManagerVO.ContactInfoVO[0].cityList,ContactInfoVO[0].cityList]; arguments []; default message [ContactInfoVO[0].cityList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'ContactInfoVO[0].cityList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.admin.command.CityVO] for property 'cityList[0]': no matching editors or conversion strategy found] 
    Field error in object 'ManagerVO' on field 'ContactInfoVO[0].countryList': rejected value [31]; codes [typeMismatch.ManagerVO.ContactInfoVO[0].countryList,typeMismatch.ManagerVO.ContactInfoVO.countryList,typeMismatch.ContactInfoVO[0].countryList,typeMismatch.ContactInfoVO.countryList,typeMismatch.countryList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [ManagerVO.ContactInfoVO[0].countryList,ContactInfoVO[0].countryList]; arguments []; default message [ContactInfoVO[0].countryList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'ContactInfoVO[0].countryList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.admin.command.CountryVO] for property 'countryList[0]': no matching editors or conversion strategy found] 
    Field error in object 'ManagerVO' on field 'ContactInfoVO[0].stateList': rejected value [601]; codes [typeMismatch.ManagerVO.ContactInfoVO[0].stateList,typeMismatch.ManagerVO.ContactInfoVO.stateList,typeMismatch.ContactInfoVO[0].stateList,typeMismatch.ContactInfoVO.stateList,typeMismatch.stateList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [ManagerVO.ContactInfoVO[0].stateList,ContactInfoVO[0].stateList]; arguments []; default message [ContactInfoVO[0].stateList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'ContactInfoVO[0].stateList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.admin.command.StateVO] for property 'stateList[0]': no matching editors or conversion strategy found] 

누군가가 해결 방법을 말해 주시겠습니까?

답변

1

출력에 오류가 있습니다. 도메인 클래스 필드 ContactInfoVO[0].cityListListString 값을 설정하려고합니다.

도메인 클래스 코드 등을 보지 않아도 귀하의 페이지가 의도 한 바가 무엇인지 알기가 어렵습니다. 사용자가 결정한 단일 값으로 데이터베이스를 채우려는 경우 공통 테이블에서 다른 테이블 (또는 클래스/열거 형)의 값으로 선택 드롭 다운을 채우고 사용자가 선택한 단일 값을 자체 테이블로 설정합니다 클래스/테이블. 같은 수업으로 두 가지 일을하려고하는 것 같습니다.

+0

나는 단지 도시를 국가 및 국가에 기초하여 채우기 위해 노력하고 있습니다. 양식 제출시 저는 cityId 만 사용하게 될 것입니다. 세 개의 필드 (국가, 주,시)에는 모두 선택 상자가 채워지는 자체 마스터 테이블이 있습니다. 이제 제출을 클릭하면 컨트롤러에 도달하기 전에 봄에이 오류가 발생합니다. 즉, 모델 속성의 바인딩이 실패했다는 의미입니다. 내 컨트롤러에서 도시 만 얻을 수 있도록 나에게 뭔가 제안 해 줄 수있어? – Sachin

+1

다른 경로에 바인딩하려면'

'를 변경해야한다고 생각합니다. 하나는'List'가 아닌'String' 값을 취합니다. ContactInfoVO [0] .cityList는 List를 필요로하며이를 String으로 설정하려고합니다. 따라서 cityId를 데이터를 저장할 테이블이 아닌 마스터 목록으로 되돌려 놓으려는 것 같습니다. – nickdos

+0

감사합니다. 어떻게 이전에이 사실을 알지 못했는지 모르겠지만 (그러나이 문제는 수정되었습니다. – Sachin

0

countryInd를 ContactInfoVO [0] .countryList로 설정하려고합니다. 따라서 정수를 목록으로 설정합니다.

나는 문제가 여기에 생각 :

<form:select path="ContactInfoVO[0].countryList" multiple="single" id="country"> 

내가 거기 countryList을보고 이해가되지 않습니다. 오히려 ContactInfo[0].countryId과 같아야합니다.이 경우 "${country.countryId}"

게시물 ContractInfoVO 클래스와 태그가 더 명확 할 것입니다.