3

I am using spring webmvc for my project, and there i am using @ModelAttribute annotation in controller action to bind the form data to model. ModelAttribute is binding data fine if i am sending data in x-www-form-urlencoded form.But if i am sending data in simple form-data then it is not binding.

I am sending request using POSTMAN Rest Client, below is the format of my request -

POST /register-school HTTP/1.1
Host: localhost:8080
Accept: application/json
Cache-Control: no-cache

----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="email"

testing@test.com
----WebKitFormBoundaryE19zNvXGzXaLvS5C

For this above request my ModelAttribute is not binding data to object.

But Its working if i am sending request in x-www-form-urlencoded

POST /register-school HTTP/1.1
Host: localhost:8080
Accept: application/json
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

email=testing%40test.com

Is there is any way to make ModelAttribute to work with form-data also?

vivex
  • 2,496
  • 1
  • 25
  • 30
  • Please provide a reproducible example where form-data fails. – Sotirios Delimanolis May 20 '15 at 05:05
  • I am testing my app with postMan , here is the preview of form-data request -POST /register-school HTTP/1.1 Host: localhost:8080 Accept: application/json Cache-Control: no-cache ----WebKitFormBoundaryE19zNvXGzXaLvS5C Content-Disposition: form-data; name="var2" value1 ----WebKitFormBoundaryE19zNvXGzXaLvS5C – vivex May 20 '15 at 05:07

0 Answers0