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