Incapable de corriger: "java.lang.Chaîne "de type" java.util.Collection"

Je reçois ce message d'erreur quand je soumettre mon formulaire et ne peut pas comprendre pourquoi cela se passe. Je crois que la taglib devrait être de la manipulation de ce. J'ai essayé de changer la valeur passée dans ma jsp pour itemValue="id" mais il n'a aucun effet.

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'content' on field 'stateCollection': rejected value [com.myapp.cmt.model.State[ id=3 ]]; codes [typeMismatch.content.stateCollection,typeMismatch.stateCollection,typeMismatch.java.util.Collection,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [content.stateCollection,stateCollection]; arguments []; default message [stateCollection]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Collection' for property 'stateCollection'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [java.lang.String] to required type [com.myapp.cmt.model.State] for property 'stateCollection[0]': no matching editors or conversion strategy found]

Ma jsp

<strong>State</strong><br/>
<form:checkboxes path="stateCollection" items="${states}" itemLabel="name"/>

Mon Contenu

public class Content implements Serializable {
.......

    @JoinTable(name = "content_to_state", joinColumns = {
        @JoinColumn(name = "content_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "state_id", referencedColumnName = "id")})
    @ManyToMany
    private Collection<State> stateCollection;

.....

    @XmlTransient
    public Collection<State> getStateCollection() {
        return stateCollection;
    }

    public void setStateCollection(Collection<State> stateCollection) {
        this.stateCollection = stateCollection;
    }

.....

Mon Contrôleur

...
@RequestMapping(value = "/{guid}/save", method = RequestMethod.POST)
public ModelAndView saveContent(@ModelAttribute("content") Content content, @PathVariable("guid") String guid) {
    try {
        //Save the modified object
        contentService.save(content);
    } catch (IllegalOrphanException ex) {

...

Le contenu de mon service

...
@Transactional
public void save(Content content) throws IllegalOrphanException, NonexistentEntityException, RollbackFailureException, Exception {
    try {
        utx.begin();
        em.merge(content);

        utx.commit();
    } catch (Exception ex) {

    } finally {
        if (em != null) {
            em.close();
        }
    }
}

...
InformationsquelleAutor Webnet | 2012-04-05