简体   繁体   中英

Form binding in Spring MVC

I have the following domain classes in my app

class Video {
    private Image image;
}

class Image {
    private final Map<ImageType, ImageAsset> images 
}

class ImageAsset {
    Url href;
}

enum ImageType {
   S1, S2, S3;
}

So basically a Video has 1 Image which has N ImageAssets - which are mapped by ImageType.

In my Spring MVC form - I bind it to the Video object in the Model:

<form:form commandName="video">

One of the fields of the form needs to be bound to the href field of a given ImageAsset. I would have expected to do it thus:

<form:imput path="image.images[S1].href" />

but this returns the error:

Invalid property 'image.images[S1].href' of bean class [Image]

removing the "href" from the expression returns something - I think its an ImageAsset, but I cannot access anymore properties form there.

How do I bind this form field to the href property of ImageAsset?

Thanks -

Avja Zelur found solution himself :

ImageAsset didn't conform to the JavaBean spec. Sorted!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM