I am using Spring MVC 3 and I want to make an AJAX call sending an array of objects to a controller. I want my Java to look like this:
@RequestMapping (value = "/data/save/faults" method = RequestMethod.GET)
public void saveFaultsGET
(
@RequestParam ("faults") FaultType[] types
) { }
Note the FaultType is an object I wrote. I am using jQuery and I am not sure how I would format my request URL to achieve this. It would also be helpful to know if it’s not possible.
EDIT FaultType looks like this (getters and setters omitted):
public class FaultType {
private String m_type;
private boolean m_isTrip;
private boolean m_isRelay;
private boolean m_isNonRelay;
}
This is very good intro : http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
The ajax call should look something like this:
Your controller signature should look something like this:
Why do you want to send objects using a get request, POST is the defacto method for posting data to server. Also, you don’t have to return a responsebody, you can also return a modelAndView.