简体   繁体   中英

Spring Data REST event handler send JSON response

I've been working on a Spring (backend) and ExtJS (UI) application. I am using Spring Data REST to reduce code, with just an interface am able to do CRUD on my web endpoints. The hard nut is getting my event handlers to send JSON response back to my client after an event such as before and after crud. My handlers are registered and working since events are being logged on the console. Now I need to send such a response if create bank is successful

{success:true, 'msg':'Bank created successfully '

Help?

If you take a look at fundamentals , your code would depend on the http response status codes and headers after creation/update/delete requests. Note the headers for resources created. Optionally you could configure to return the content ( RepositoryRestConfiguration.returnBodyOnCreate & RepositoryRestConfiguration.returnBodyOnUpdate ) using if you prefer.

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