java web 总结,java_web总结(一)

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;

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值