html - Spring MVC + jsp: How to receive a list of items in controllers? -
the requirement letting users upload list of tickets like:
@requestmapping(value="/tickets", method=requestmethod.post) public void uploadtickets( @requestbody list<ticket> tickets) { // list of tickets }
i know how upload single ticket. need create html form 3 fields (section, row, seat) , submit button. spring automatically convert uploaded form ticket object. not sure how upload list of tickets spring controllers. help? thanks!
this depends on configuration. assuming normal spring configuration.
you upload single ticket json request
{ "section":"", "seat":"", "row":"" }
to list of tickets, use json array.
[ { "section":"", "seat":"", "row":"" }, ......., { "section":"", "seat":"", "row":"" } ]
to data format, of course depends on front end. might need javascript on frontend format.
Comments
Post a Comment