jeudi 28 avril 2016

spring form checkbox id creation fails

I was trying an example which shows list of books with checkbox for each book. by using

<form:checkboxes items="${book.allBooks}"  path="selectedBooks"/>

</form:form>

Here book object is backing object. Here if I see view source of my JSP, it shows the id for each checkbox as selectedBooks1, selectedBooks2 etc. But I want the ID be like --

When I tried to include ID attribute for form:checkboxes as id="chk_${book.allBooks.isbn}" getting exception pasted below.

NOTE: I have getter and setter for isbn paramater in my Book class and it is of type int. Any help is appreciated. thanks

it throws exception as

root cause:

java.lang.NumberFormatException: For input string: "isbn"
java.lang.NumberFormatException.forInputString(Unknown Source)




Aucun commentaire:

Enregistrer un commentaire