當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeWebRequest.getNativeResponse方法代碼示例

本文整理匯總了Java中org.springframework.web.context.request.NativeWebRequest.getNativeResponse方法的典型用法代碼示例。如果您正苦於以下問題:Java NativeWebRequest.getNativeResponse方法的具體用法?Java NativeWebRequest.getNativeResponse怎麽用?Java NativeWebRequest.getNativeResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.context.request.NativeWebRequest的用法示例。


在下文中一共展示了NativeWebRequest.getNativeResponse方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleTimeout

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
@Override
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception {
	HttpServletResponse servletResponse = request.getNativeResponse(HttpServletResponse.class);
	if (!servletResponse.isCommitted()) {
		servletResponse.sendError(HttpStatus.SERVICE_UNAVAILABLE.value());
	}
	return false;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:TimeoutDeferredResultProcessingInterceptor.java

示例2: handleReturnValue

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
    HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);

    ExcelResponseBody annotation = returnType.getMethodAnnotation(ExcelResponseBody.class);
    ExcelType type = annotation.type();
    String fileName = annotation.name() + type.suffixName();

    servletResponse.setContentType("application/vnd.ms-converter");
    servletResponse.setHeader("content-disposition", "attachment;filename=" + fileName);
    List<?> excel;
    if (returnValue instanceof List) {
        excel = (List<?>) returnValue;
    } else {
        excel = Collections.singletonList(returnValue);
    }

    if (converters.supportsExcelType(type)) {
        try (Workbook workbook = converters.toExcel(annotation, excel)) {
            workbook.write(servletResponse.getOutputStream());
            servletResponse.flushBuffer();
        } catch (IOException ignored) {
            ;
        }
    }


}
 
開發者ID:natsuforyou,項目名稱:spring-boot-excel-plugin,代碼行數:29,代碼來源:ExcelRequestResponseBodyHandler.java

示例3: handleTimeout

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
@Override
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) throws Exception {
	HttpServletResponse servletResponse = request.getNativeResponse(HttpServletResponse.class);
	if (!servletResponse.isCommitted()) {
		servletResponse.sendError(HttpStatus.SERVICE_UNAVAILABLE.value());
	}
	return CallableProcessingInterceptor.RESPONSE_HANDLED;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:TimeoutCallableProcessingInterceptor.java

示例4: handleReturnValue

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void handleReturnValue(Object returnValue, MethodParameter returnType,
                              ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
        throws IOException, HttpMediaTypeNotAcceptableException {
    mavContainer.setRequestHandled(true);
    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    JsonResult jsonResult = new JsonResult(returnValue);
    response.setContentType("application/json; charset=UTF-8");
    JsonUtil.writeValue(response.getWriter(), jsonResult);
}
 
開發者ID:didapinchegit,項目名稱:rocket-console,代碼行數:11,代碼來源:JsonBodyReturnValueProcessor.java

示例5: handleReturnValue

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
                              ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
    mavContainer.setRequestHandled(true);
    HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);
    ServletServerHttpResponse outputMessage = new ServletServerHttpResponse(servletResponse);
    outputMessage.getBody();
    HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
    WxRequest wxRequest = WxWebUtils.getWxRequestFromRequest(request);
    wxAsyncMessageTemplate.send(wxRequest, returnValue);
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:12,代碼來源:WxAsyncMessageReturnValueHandler.java

示例6: createHttpOutputMessage

import org.springframework.web.context.request.NativeWebRequest; //導入方法依賴的package包/類
private HttpOutputMessage createHttpOutputMessage(NativeWebRequest webRequest) throws Exception {
    HttpServletResponse servletResponse = (HttpServletResponse) webRequest.getNativeResponse();
    return new ServletServerHttpResponse(servletResponse);
}
 
開發者ID:PatternFM,項目名稱:tokamak,代碼行數:5,代碼來源:RestExceptionRenderer.java


注:本文中的org.springframework.web.context.request.NativeWebRequest.getNativeResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。