简体   繁体   中英

Spring Roo Gvnix. Json response on mvc controller request with form data parameters

I need to generate a Json response for a POST made with parameters in form data, not in Json.

Example: My request:

curl -X POST -H "Accept: application/json" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "firstName=Manolete" -F "lastName=Manolón" -F "address=villa arriba" -F "city=meryville" -F "telephone=666666666" -F "homepage=alguna.homepage.es" -F "email=alguno@hotmail.com" -F "birthday=1314595427866" " http://localhost:8080/PetClinicRoo/owners "

Current request:

curl -X POST -H "Accept: application/json" -d '{firstName: "Manolete", lastName:"Manolón", address:"villa arriba", city: "Meryville", telephone:"66666666", homepage:"alguna.homepage.es", email:"alguno@hotmail.com", birthDay: 1314596527943, }' " http://localhost:8080/PetClinicRoo/owners "

I could handwrite the code but this implies getting out of spring roo management all the application web tier, and further modifications wouldn't be automatically made.

您可以插入控制器方法并根据需要对其进行修改,Spring Roo管理将起作用。

We have several options:

1.- Use spring roo and then pushing in the methods

  • Generate all the web tier using spring roo

  • Pushing-in all the post methods

  • Modify the response

Inconvenients: once you push-in the methods, spring roo doesn't manage them, so further modifications woldn't be made automatically

2.-Handwrite the web tier.

  • Use spring ro to generate entities

  • Handwrite the web layer

Inconvenients: implies more work than the previous option.

3.- Extend Spring Roo in order to generate the method automatically.

I think this is our best option because he have a lot of entities.

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