本文整理匯總了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;
}
示例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) {
;
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}