当前位置: 首页>>代码示例>>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;未经允许,请勿转载。