@At("/exportExcel")
@Ok("raw")
return f;
直接返回文件,文件在服务器上保留么,可以不保留么
或者直接输出:
@At("/export/?")
@Ok("void")
public void export(String id, HttpServletResponse response) {
try {
J4EConf j4eConf = J4EConf.from(Yc_activity_sign.class);
List<J4EColumn> jcols = j4eConf.getColumns();
for (J4EColumn j4eColumn : jcols) {
if ("opBy".equals(j4eColumn.getFieldName()) || "opAt".equals(j4eColumn.getFieldName()) || "delFlag".equals(j4eColumn.getFieldName())) {
j4eColumn.setIgnore(true);
}
}
List<Yc_activity_sign> list = ycActivitySignService.query(Cnd.where("activityId", "=", id));
OutputStream out = response.getOutputStream();
response.addHeader("content-type", "application/shlnd.ms-excel;charset=utf-8");
response.addHeader("content-disposition", "attachment; filename=activity_detail.xls");
J4E.toExcel(out, list, j4eConf);
} catch (Exception e) {
e.printStackTrace();
}
}