简体   繁体   中英

Passing Backbone collection to Spring

So I have a Backbone collection and a bunch of fields in a form that I would like to do a $.ajax call on (probably a GET). In order to access this data, what should I put in the data field for the $.ajax function and what annotation(is it @RequestParam?) should I use to get the collection and the components of the form out in Java Spring?

Thanks.

I don't use Spring directly but I don't think it should be any different then accepting JSON or HTTP Form data or XML for that matter.

You could simply format your data as key-value pairs and send it: (it'll need to be parsed as a form in Spring)

$.ajax({
    data:'var1=value1&var2=value2'
});

or just send a JSON object and set the contentType to JSON (or build an XML if you wish) It's totally upto you.

Depending on what format you select you must set the contentType appropriately. You can read more about the ajax properties here

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