本文整理汇总了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);
}