當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。