How to post response from worker thread to client via Spring MVC?

I am using spring tool suite 3.3.0.

I have a request mapping in that I receive from client and start processing and call a different thread for my purpose.

Is it possible to send response from worker thread?

Code: @RequestMapping(value = "/rcv", method = RequestMethod.POST)

public @ResponseBody String home() { //receving from client

 Thread th = new Thread();
 // my thread process

}


No. It should work another way.

On first cll you start the thread nd store it somewhere eg in session. Then from client you call it from time to time eg by AJAX call each second you ask whether the thread's job is done. BTW it could also show the progress.

When thread has done the job the result is stored again in session and on next AJAX call the result is returned to client

链接地址: http://www.djcxy.com/p/48474.html

上一篇: spring mvc控制器接受具有可变数目的键/值的JSON对象

下一篇: 如何通过Spring MVC发布工作线程对客户端的响应?