Announcement Announcement Module
No announcement yet.
Spring MVC REST WebService, how to pass/get ArrayList from client/server application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC REST WebService, how to pass/get ArrayList from client/server application

    Hi All,

    I have created a sample application to get full idea of Spring MVC with REST Webservice. I have created an application which host webservice and a client which calls to this webservice and fetch the relevant data. I am able to pass the arguments from client side like String, and able to receive the data as List or single object, and till here it goes smooth..

    Now I want to pass the List as an argument from client side, and also want to implement on webservice side to get the List which is passed from client application. Can anyone helpout with this scenario?

    Please find code snippet of my working version.

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("appContext.xml", Client.class);
        RestTemplate restTemplate = applicationContext.getBean("restTemplate", RestTemplate.class);
        String url;
        // retrieve a list of customers
        url = "http://localhost:8080/restful-ws/app/testlist.xml";
        List<CustomerBean> custList = (List) restTemplate.getForObject(url, List.class);
        for (CustomerBean cust : custList) {
          System.out.println(">> cust :"+ cust.toString());
    Web Service side implementation.

    	@RequestMapping(method=RequestMethod.GET, value="/testlist")
    	public ModelAndView showCustomers() {
    		ModelAndView mv = new ModelAndView("customerListKey");
    		List<Customer> custs = new ArrayList<Customer>();
    		for (Customer customer:customers.values()) {
    		mv.addObject("allCustomers", custs);
    		return mv;

    also i have related files, but if will put all code snippets, it will become too much. Mainly my query is how can I pass List from client side and how can i get it from receiver/server side?, in both side i am using spring only

    Thanks in advance for your time and help.