码迷,mamicode.com
首页 > 编程语言 > 详细

java_web总结(一)

时间:2014-08-19 18:34:25      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   java   os   io   文件   

1、struts1ajax返回值

     

	public ActionForward preChangeAccountPwd(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
               // 向页面返回添加帐号结果
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		PrintWriter  pw = response.getWriter();
		pw.write(result);
		pw.close();
                return null;
}        

2、excle

response.setHeader("Content-disposition","attachment;filename=temp.xls"); 
response.setContentType("application/octet-stream");
ServletOutputStream os = response.getOutputStream();
NetWorkForm uf = (NetWorkForm)form;
FormFile ff = uf.getNetFile();
InputStream in = ff.getInputStream();
HSSFWorkbook wb = new HSSFWorkbook(in);
HSSFSheet sheet = wb.getSheetAt(0);
int rowNum = sheet.getLastRowNum();
×
×
workbook.write(os);
os.close();
in.close();
return null;
========================
OutputStream os = response.getOutputStream();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename="+ fileName+ ".xls");
// 第一步,创建一个webbook,对应一个Excel文件
HSSFWorkbook wb = new HSSFWorkbook();
×
×
wb.write(os);
os.close();
response.setContentType("text/xml;charset=utf-8");
return null;

    

     

java_web总结(一),布布扣,bubuko.com

java_web总结(一)

标签:style   blog   http   color   java   os   io   文件   

原文地址:http://www.cnblogs.com/caroline4lc/p/3922673.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!