当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletResponse.setBufferSize方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.setBufferSize方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.setBufferSize方法的具体用法?Java HttpServletResponse.setBufferSize怎么用?Java HttpServletResponse.setBufferSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.setBufferSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exportExcel

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 导出
 * @param modelName 模型名称
 * @param excelType excel格式
 * @param response
 * @return
 * @throws IOException
 */
@RequestMapping(value = { "/excel/{modelName}","/excel/{modelName}/{excelType}" }, method = RequestMethod.GET)
public void exportExcel(@PathVariable String modelName,@PathVariable(required = false) String excelType, HttpServletResponse response) throws IOException {
    //默认导出xls格式excel
    if(excelType==null||"".equals(excelType)){
        excelType="XLS";
    }
    List<SysExportModel> models = modelService.queryExportModelByCondition(modelName);
    // 模型不存在 直接结束
    if (models == null || models.size() == 0) {
        return;
    }
    // 获取导出数据
    SysExportModel model = models.get(0);
    List<List<Object>> exportData = commonService.getAllData(model.getModelName(), model.getEnames(), null);
    List<String> exportHeaderNames = new ArrayList<String>();
    String[] headerNames = model.getCnames().split(",");
    for (String headerName : headerNames) {
        exportHeaderNames.add(headerName);
    }

    response.reset();
    // 文件下载
    response.setContentType("application/vnd.ms-excel");
    String filename = "报表"+modelName+"("+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ ")";

    filename = new String(filename.getBytes("gbk"), "iso-8859-1");
    response.setHeader("Content-disposition", "attachment;filename="+ filename + "."+excelType.toLowerCase());
    response.setBufferSize(1024);

    //获取excel表单
    ExcelGenerater excelGenerater=new ExcelGenerater();
    ExcelGeneraterBean excelGeneraterBean = excelGenerater.create(modelName, exportHeaderNames, exportData);
    Workbook workbook = excelGeneraterBean.getWorkbook();
    //写入数据 到流
    workbook.write(response.getOutputStream());
    workbook.close();
}
 
开发者ID:babymm,项目名称:mumu,代码行数:46,代码来源:ExportController.java

示例2: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override          
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
             response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.setBufferSize(8192);
             
             switch (Integer.parseInt(request.getParameter("case")))
             {
                  case 1 :  getServletContext().getRequestDispatcher("/entryreview.jsp").forward(request,response);  
                            return;
                  case 2 :  getServletContext().getRequestDispatcher("/place_entry.jsp").forward(request,response);
                            return;
                  case 3 :  getServletContext().getRequestDispatcher("/updatemobno.jsp").forward(request,response);
                            return;
                  case 4 :  getServletContext().getRequestDispatcher("/updatepassword.jsp").forward(request,response);
                            return;
                  case 5 :  getServletContext().getRequestDispatcher("/updateemail.jsp").forward(request,response);
                            return;
                  default : request.setAttribute("uid", request.getParameter("uid"));
                            getServletContext().getRequestDispatcher("/successlogin.jsp").forward(request,response);
                            return;
             }
     }
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:25,代码来源:SchUtil.java

示例3: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override          
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
            response.setContentType("text/html");
     response.setCharacterEncoding("UTF-8");
     response.setBufferSize(8192);
        
        switch (Integer.parseInt(request.getParameter("case")))
        {
             case 1 :  getServletContext().getRequestDispatcher("/entryreview.jsp").forward(request,response);  
                       return;
             case 2 :  getServletContext().getRequestDispatcher("/place_entry.jsp").forward(request,response);
                       return;
             case 3 :  getServletContext().getRequestDispatcher("/updatemobno.jsp").forward(request,response);
                       return;
             case 4 :  getServletContext().getRequestDispatcher("/updatepassword.jsp").forward(request,response);
                       return;
             case 5 :  getServletContext().getRequestDispatcher("/updateemail.jsp").forward(request,response);
                       return;
             default : request.setAttribute("uid", request.getParameter("uid"));
                       getServletContext().getRequestDispatcher("/successlogin.jsp").forward(request,response);
                       return;
        }
}
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:25,代码来源:SchUtil.java

示例4: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
    @SuppressWarnings({"unchecked", "unchecked"})
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
                 response.setContentType("text/json");
    response.setCharacterEncoding("UTF-8");
    response.setBufferSize(8192);
                 PrintWriter out = null;
                 
                 if (Validate.isUserExists(request.getParameter("uid"),request.getParameter("pass")))
                 {
                                  out=response.getWriter();
                                  out.print("Login Success!! \n"
                                              +"Welcome User : "+request.getParameter("uid")+" \n");
                                  out.flush();
                                  out.close();
                 }
                 else
                    {
                          out=response.getWriter();
                          out.print("ERROR!! \n"
+ "FAILED!!! Incorrect User_Id Or Password. \n"
                                      + "REASON -- User/Password Does Not Exist!! \n"
+ "Please Enter Correct Credentials!! \n");
                          out.flush();
                          out.close();
                    }
                 return;
    }
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:30,代码来源:AndroServlet.java

示例5: getAttachmentContent

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping(value = "/email/attachment/{id}",method = RequestMethod.GET)
public void getAttachmentContent(@PathVariable("id") Long id, HttpServletResponse response) {

	final AttachmentEntity attachment = attachmentService.findAttachmentById(id);

	if (attachment != null) {
		try {
			ServletOutputStream stream = response.getOutputStream();
			OutputStream out = new BufferedOutputStream(stream);

			response.resetBuffer();
			response.setBufferSize(attachment.getAttachmentContent().getData().length);
			response.setHeader("Content-Length", String.valueOf(attachment.
                       getAttachmentContent().getData().length));

			out.write(attachment.getAttachmentContent().getData());

			out.close();
			stream.close();
		} catch (final IOException e) {
			log.error("Unable to open file", e);
		}
	} else {
		log.error("File does not exist");
	}
}
 
开发者ID:dopse,项目名称:maildump,代码行数:27,代码来源:EmailController.java

示例6: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    resp.setBufferSize(bufferSize);

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    resp.setContentLength(responseSize);

    PrintWriter pw = resp.getWriter();
    for (int i = 0; i < responseSize; i++) {
        pw.append('X');
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:TestAbstractAjpProcessor.java

示例7: downloadFile

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping(value = "/download", method = RequestMethod.GET)
public
@ResponseBody
void downloadFile(@RequestParam String key, @RequestParam(required = false) boolean isBlobKey,
                  @RequestParam(required = false) String fileName, HttpServletRequest request,
                  HttpServletResponse response) {
  SecureUserDetails sUser = SecurityUtils.getUserDetails(request);
  Locale locale = sUser.getLocale();
  ResourceBundle backendMessages = Resources.get().getBundle("BackendMessages", locale);
  if (key == null || key.isEmpty()) {
    throw new BadRequestException(backendMessages.getString("file.download.error"));
  }
  try {
    String blobKeyStr;
    String downloadFileName;
    if(!isBlobKey) {
      UploadService us = Services.getService(UploadServiceImpl.class);
      IUploaded uploaded = us.getUploaded(key);
       blobKeyStr = uploaded.getBlobKey();
      downloadFileName = uploaded.getFileName();
    } else {
      blobKeyStr = key;
      downloadFileName = fileName;
    }
    response.addHeader("Content-Disposition", "attachment; filename=" + downloadFileName);
    response.setBufferSize(32*1024);
    if (blobKeyStr != null) {
      AppFactory.get().getBlobstoreService().serve(blobKeyStr, response);
    }
    response.flushBuffer();
  } catch (ServiceException | ObjectNotFoundException | IOException e) {
    xLogger.warn("Error in downloading file", e);
    throw new InvalidServiceException(backendMessages.getString("file.download.error"));
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:ExportController.java

示例8: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
        @SuppressWarnings({"unchecked", "unchecked"})
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        {
                     response.setContentType("text/json");
              response.setCharacterEncoding("UTF-8");
              response.setBufferSize(8192);
                     PrintWriter out = null;
                     
String usrid = Validate.isUserExists(request.getParameter("uidoreml"),request.getParameter("pass"));
                     if ( usrid != null )
                     {
                                      out=response.getWriter();
                                      out.print("Login Success!! \n"
                                                  +"Welcome User : "+usrid+" \n");
                                      out.flush();
                                      out.close();
                     }
                     else
                        {
                              out=response.getWriter();
                              out.print("ERROR!! \n"
                     + "FAILED!!! Incorrect User_Id Or Password. \n"
                                          + "REASON -- User/Password Does Not Exist!! \n"
                     + "Please Enter Correct Credentials!! \n"
	      + "Be careful about spaces and character cases!! \n");
                              out.flush();
                              out.close();
                        }
                     return;
        }
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:32,代码来源:AndroServlet.java


注:本文中的javax.servlet.http.HttpServletResponse.setBufferSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。