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