springmvc-비동기 요청 - DeferredResult로 돌아가기

4466 단어 java 기초
61、springmvc- - DeferredResult

1. DeferredResult<Object> deferredResult . 
2. deferredResult deferredResult.setResult(order); ,response 
3. , .

	@ResponseBody
	@RequestMapping("/createOrder")
	public DeferredResult<Object> createOrder(){
     
		DeferredResult<Object> deferredResult = new DeferredResult<>((long)3000, "create fail...");
			
		DeferredResultQueue.save(deferredResult);
		
		return deferredResult;
	}
	
	
	@ResponseBody
	@RequestMapping("/create")
	public String create(){
     
		// 
		String order = UUID.randomUUID().toString();
		DeferredResult<Object> deferredResult = DeferredResultQueue.get();
		deferredResult.setResult(order);
		return "success===>"+order;
	}

좋은 웹페이지 즐겨찾기