0

How can I call the method below using a http post. Is it necessary to use JSON and @Requestbody. I also don't wont to use spring forms.

I am not seeing any way to accomplish this without a JSON post. How would the html form lok like?

@Requestmapping(value="/post", method=RequestMethod.POST)
public void post(List<MyCustomObject> myList, AnotherCustom object){
    System.out.println("POST")
}

This is how long i come so far. This works bu how to create collection from ahtml from?

Controller

@RequestMapping(value="/post" , method=RequestMethod.POST)
public String post(Person person){
    System.out.println(person);
    return "home";
}

My form

<form method="post" action="/application/post">
    <input name="firstName"> <input name="lastName"> 
    <input type="submit">
</form>
pethel
  • 5,397
  • 12
  • 55
  • 86
  • @Firoz Thank you. That would be interesting so please do. The thing though is that I am not creating the front end so Spring taglib will not be used. I am just creating the API – pethel Sep 30 '12 at 11:55

1 Answers1

1

Follow below URL for sample code to pass data to controller(HTML form) and unit test controller.

https://github.com/ffazil/SpringMVC

FFL
  • 669
  • 7
  • 22