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


Java HttpServletResponse.reset方法代码示例

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


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

示例1: code

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 生成代码
 */
@RequestMapping("/code")
@RequiresPermissions("sys:generator:code")
public void code(HttpServletRequest request, HttpServletResponse response) throws IOException{
	String[] tableNames = new String[]{};
	//获取表名,不进行xss过滤
	HttpServletRequest orgRequest = XssHttpServletRequestWrapper.getOrgRequest(request);
	String tables = orgRequest.getParameter("tables");
	tableNames = JSON.parseArray(tables).toArray(tableNames);
	
	byte[] data = sysGeneratorService.generatorCode(tableNames);
	
	response.reset();  
       response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\"");  
       response.addHeader("Content-Length", "" + data.length);  
       response.setContentType("application/octet-stream; charset=UTF-8");  
 
       IOUtils.write(data, response.getOutputStream());  
}
 
开发者ID:guolf,项目名称:pds,代码行数:22,代码来源:SysGeneratorController.java

示例2: 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

示例3: handleError

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void handleError(final HttpServletRequest request, final HttpServletResponse response)
		throws IOException {
	// handle limit case, e.g. return status code 429 (Too Many Requests)
	// see http://tools.ietf.org/html/rfc6585#page-3
	final String text = "TOO_MANY_REQUESTS";
	response.reset();
	response.setStatus(429);
	response.setContentType("text/plain");
	response.setCharacterEncoding("US-ASCII");
	response.setContentLength(text.length() + 2);
	response.setHeader("Pragma", "no-cache");
	response.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate");
	final ServletOutputStream out = response.getOutputStream();
	out.println(text);
	out.flush();
	response.flushBuffer();
}
 
开发者ID:ggrandes,项目名称:concurrentlimit-servlet-filter,代码行数:18,代码来源:ConcurrentLimitFilter.java

示例4: DownloadExcelUtil

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 设置文件名和工作表名(Excel)
 * 
 * @param response
 *            为NULL时,写入磁盘
 * @param fileName
 *            文件名
 * @param sheetName
 *            工作表名
 * @throws IOException
 */
public DownloadExcelUtil(HttpServletResponse response, String fileName, String sheetName) throws IOException {
    startTime = System.currentTimeMillis();
    if (fileName.indexOf(".xls") < 0) {
        fileName += ".xls";
    }
    if (response != null && response instanceof HttpServletResponse) {
        logger.warn("Write Excel To Memory.Please wait...");
        response.reset();
        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
        response.setHeader("Content-Disposition",
            "attachment;filename=" + new String(fileName.getBytes("GB2312"), "ISO8859-1"));

        os = response.getOutputStream();// 获得输出流
        os.flush();
        wbook = Workbook.createWorkbook(os); // 创建excel文件
    } else {
        logger.warn("Write Excel To Disk.Please wait...");
        wbook = Workbook.createWorkbook(new File(fileName)); // 创建excel文件
    }
    this.sheetName = sheetName;
    wsheet = wbook.createSheet(sheetName, sheetIndex++); // sheet名称
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:34,代码来源:DownloadExcelUtil.java

示例5: DownloadExcelUtil

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 设置文件名和工作表名(Excel)
 * 
 * @param response
 *            为NULL时,写入磁盘
 * @param fileName
 *            文件名
 * @param sheetName
 *            工作表名
 * @throws IOException
 */
public DownloadExcelUtil(HttpServletResponse response, String fileName, String sheetName)
                                                                                       throws IOException {
    startTime = System.currentTimeMillis();
    if (fileName.indexOf(".xls") < 0) {
        fileName += ".xls";
    }
    if (response != null && response instanceof HttpServletResponse) {
        log.warn("Write Excel To Memory.Please wait...");
        response.reset();
        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
        response.setHeader("Content-Disposition",
            "attachment;filename=" + new String(fileName.getBytes("GB2312"), "ISO8859-1"));

        os = response.getOutputStream();// 获得输出流
        os.flush();
        wbook = Workbook.createWorkbook(os); // 创建excel文件
    } else {
        log.warn("Write Excel To Disk.Please wait...");
        wbook = Workbook.createWorkbook(new File(fileName)); // 创建excel文件
    }
    this.sheetName = sheetName;
    wsheet = wbook.createSheet(sheetName, sheetIndex++); // sheet名称
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:35,代码来源:DownloadExcelUtil.java

示例6: displayPDF

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void displayPDF() throws IOException {
    HttpServletResponse response = (HttpServletResponse) this.facesContext
            .getExternalContext().getResponse();

    response.reset();
    response.setContentType(this.contentType);
    response.setContentLength(this.content.length);

    response.addHeader("Content-Disposition",
            this.getDisplayType(this.displayType) + "; " + "filename="
                    + this.filename);
    response.addHeader("Accept-Ranges", "bytes");

    BufferedOutputStream outputStream = new BufferedOutputStream(
            response.getOutputStream());
    outputStream.write(this.content);
    outputStream.flush();
    outputStream.close();

    facesContext.responseComplete();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:ExternalPriceModelDisplayHandler.java

示例7: exportTemplate

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 导出当前网站当前的模版文件,包含模版页面,模版变量、栏目
 * @throws FileNotFoundException
 * @throws UnsupportedEncodingException
 */
@RequestMapping("exportTemplate")
public void exportTemplate(HttpServletRequest request, HttpServletResponse response) throws FileNotFoundException, UnsupportedEncodingException {
	BaseVO vo = templateService.exportTemplate(request);
	String fileName = "template"+DateUtil.currentDate("yyyyMMdd_HHmm")+".wscso".toString(); // 文件的默认保存名
	//读到流中
	InputStream inStream = new ByteArrayInputStream(vo.getInfo().getBytes("UTF-8"));  
	
	AliyunLog.addActionLog(getSiteId(), "导出当前网站当前的模版文件");
	
	// 设置输出的格式
	response.reset();
	response.setContentType("bin");
	response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
        // 循环取出流中的数据
	byte[] b = new byte[1000];
	int len;
	try {
	    while ((len = inStream.read(b)) > 0)
	        response.getOutputStream().write(b, 0, len);
	    inStream.close();
	} catch (IOException e) {
	    e.printStackTrace();
	}
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:30,代码来源:TemplateController.java

示例8: viewFile

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping("/{codeID}/**")
public void viewFile(@PathVariable("codeID") int codeID,
		HttpServletRequest request,HttpServletResponse res) throws IOException {
	Code code = this.codeService.get(codeID,false);
	String uri = URLDecoder.decode(request.getRequestURI(),"UTF-8");
	String filePath = uri.substring(uri.indexOf("/code/")+6+(""+codeID).length());
	SimpleCode simpleCode = code.getSimpleCode(filePath);

	if (simpleCode == null) {
		res.sendRedirect("http://www.gravatar.com/avatar/a.jpg");
		return;
	}
	byte[] imgData;


	if(WebUtil.isCodeName(filePath))
		imgData = simpleCode.getContent().getBytes("EUC-KR");
	else
		imgData = simpleCode.getContent().getBytes("8859_1");

		res.reset();
		res.setContentType("application/octet-stream");
		String filename = new String(simpleCode.getFileName().getBytes("UTF-8"), "8859_1");
		res.setHeader("Content-Disposition", "attachment; filename = " + filename);

		OutputStream o = res.getOutputStream();
		o.write(imgData);
		o.flush();
		o.close();
		return;

}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:33,代码来源:CodeController.java

示例9: download

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping("/{codeID}/{codeName}.zip")
public void download(HttpServletResponse res,
		@PathVariable("codeID") int codeID,
		@PathVariable("codeName") String codeName) throws IOException {
	Code code = this.codeService.get(codeID,false);
	res.reset();
	res.setContentType("application/octet-stream");
	res.setHeader("Content-Disposition", "attachment; filename = " + codeName+".zip");
	res.setContentType(WebUtil.getFileExtension(codeName+".zip"));
	this.codeService.dowloadCode(code, res.getOutputStream());
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:12,代码来源:CodeController.java

示例10: loginForm

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Sends a 401 error to the browser. This forces a login box to be displayed
 * allowing the user to login.
 *
 * @param response
 *        the response to set the headers and status
 */
protected void loginForm(HttpServletResponse response) throws IOException {
    response.reset();
    response.addHeader("WWW-Authenticate",
            "Basic realm=\"!!Fedora Repository Server\"");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    OutputStream out = response.getOutputStream();
    out.write("Fedora: 401 ".getBytes());
    out.flush();
    out.close();
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:18,代码来源:UpstreamAuthFilterJAAS.java

示例11: write

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 输出到客户端
 * @param fileName 输出文件名
 */
public ExportExcel write(HttpServletResponse response, String fileName) throws IOException{
    response.reset();
    response.setContentType("application/octet-stream; charset=utf-8");
    response.setHeader("Content-Disposition", "attachment; filename="+Encodes.urlEncode(fileName));
    write(response.getOutputStream());
    return this;
}
 
开发者ID:sombie007,项目名称:ExcelHandle,代码行数:12,代码来源:ExportExcel.java

示例12: exportFile

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 向客户端下载文件,弹出下载框.
 *
 * @param response(HttpServletResponse)
 * @param file(需要下载的文件)
 * @param isDel(下载完成后是否删除该文件)
 * @throws IOException
 */
public static void exportFile(HttpServletResponse response, File file, boolean isDel) throws IOException {
    OutputStream out = null;
    InputStream in = null;

    // 获得文件名
    String filename = URLEncoder.encode(file.getName(), "UTF-8");
    response.reset();
    // 定义输出类型(下载)
    response.setContentType("application/x-msdownload");
    response.setHeader("Location", filename);
    // 定义输出文件头
    response.setHeader("Content-Disposition", "attachment;filename=" + filename);
    out = response.getOutputStream();
    in = new FileInputStream(file.getPath());

    byte[] buffer = new byte[1024];
    int i = -1;
    while ((i = in.read(buffer)) != -1) {
        out.write(buffer, 0, i);
    }

    in.close();
    out.close();

    if (isDel) {
        //删除文件,删除前关闭所有的Stream.
        file.delete();
    }

}
 
开发者ID:tong12580,项目名称:OutsourcedProject,代码行数:39,代码来源:Excel.java

示例13: handle

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Override
public void handle(Throwable exception, SectionInfo info, SectionsController controller, SectionEvent<?> event)
{
	LOGGER.error("Error during ajax request", exception);
	info.setRendered();
	final HttpServletResponse response = info.getResponse();
	if( !response.isCommitted() )
	{
		response.reset();
		response.setStatus(500);
		response.setHeader("Content-Type", "application/json");
		try
		{
			final Map<String, Object> message = new HashMap<String, Object>();
			final Throwable rootCause = Throwables.getRootCause(exception);
			final String errorMessage = Utils.coalesce(rootCause.getMessage(), rootCause.getClass()
				.getCanonicalName());
			message.put("message", errorMessage);
			mapper.writeValue(response.getWriter(), message);
		}
		catch( IOException e )
		{
			throw new SectionsRuntimeException(e);
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:AjaxExceptionHandler.java

示例14: handleException

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public static void handleException(HttpServletResponse response,
        Exception e, String realm, boolean sendBody) throws IOException,
        ServletException {
    if (e instanceof OAuthProblemException) {
        OAuthProblemException problem = (OAuthProblemException) e;
        Object httpCode = problem.getParameters().get(OAuthProblemException.HTTP_STATUS_CODE);
        if (httpCode == null) {
            httpCode = PROBLEM_TO_HTTP_CODE.get(problem.getProblem());
        }
        if (httpCode == null) {
            httpCode = SC_FORBIDDEN;
        }
        response.reset();
        response.setStatus(Integer.parseInt(httpCode.toString()));
        OAuthMessage message = new OAuthMessage(null, null, problem
                .getParameters().entrySet());
        response.addHeader("WWW-Authenticate", message
                .getAuthorizationHeader(realm));
        if (sendBody) {
            sendForm(response, message.getParameters());
        }
    } else if (e instanceof IOException) {
        throw (IOException) e;
    } else if (e instanceof ServletException) {
        throw (ServletException) e;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
    } else {
        throw new ServletException(e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:OAuthServlet.java

示例15: down

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public static void down(HttpServletResponse response, InputStream in, String fileName)
		throws Exception {
	fileName = URLEncoder.encode(fileName, "UTF-8");
	response.reset();
	response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
	response.setContentType("application/octet-stream;charset=UTF-8");
	IOUtils.copy(in, response.getOutputStream());
	in.close();
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:10,代码来源:FileUtil.java


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