java导出txt文件
来源:互联网 发布:明源软件北京分公司 编辑:程序博客网 时间:2024/05/22 10:41
/**
* Servlet implementation class ExportEnrollExamine
*/
@WebServlet("/ExportEnrollExamine")
public class DocFileExportLicenseServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DocFileExportLicenseServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
JSONObject jsonData = JSONObject.fromObject(request.getParameter("jsonData"));
String sqlString =BaseLicenseBaseInfo.queryCheckInfoBycheckId(jsonData.getString("checkId"));
LinkedList<HashMap<String,Object>> list = AccessDataBaseUtil.getDataTableListKeyValue(sqlString,"LIC_USER;LIC_USER_IDCARD;LIC_USER_DOCUMENT_TYPE;LIC_CALLSIGN;LIC_CODE;CHECK_STATUS");
String sqlStringLastTime =BasicLicenseCheckInfo.selectCheckInfoById(jsonData.getString("checkId"));
LinkedList<HashMap<String,Object>> lastTimeList = AccessDataBaseUtil.getDataTableListKeyValue(sqlStringLastTime,"check_end_time;check_title");
JSONObject jsonobj =new JSONObject();
JSONArray jsonarray = JSONArray.fromObject(lastTimeList);
JSONObject licenseTime = jsonarray.getJSONObject(0);
jsonobj.put("licenseData", JSONArray.fromObject(list));
jsonobj.put("licenseTime", licenseTime.get("check_end_time"));
StringBuffer write = new StringBuffer();
try {
response.setHeader("Content-Disposition", "attachment;filename="+ new String((licenseTime.get("check_title").toString()+".txt").getBytes("utf-8"), "iso8859-1"));// 设置头信息
response.setContentType("application/ynd.ms-excel;charset=UTF-8");
OutputStream out = response.getOutputStream();
write.append(jsonobj);
out.write(write.toString().getBytes("UTF-8"));
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
* Servlet implementation class ExportEnrollExamine
*/
@WebServlet("/ExportEnrollExamine")
public class DocFileExportLicenseServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DocFileExportLicenseServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
JSONObject jsonData = JSONObject.fromObject(request.getParameter("jsonData"));
String sqlString =BaseLicenseBaseInfo.queryCheckInfoBycheckId(jsonData.getString("checkId"));
LinkedList<HashMap<String,Object>> list = AccessDataBaseUtil.getDataTableListKeyValue(sqlString,"LIC_USER;LIC_USER_IDCARD;LIC_USER_DOCUMENT_TYPE;LIC_CALLSIGN;LIC_CODE;CHECK_STATUS");
String sqlStringLastTime =BasicLicenseCheckInfo.selectCheckInfoById(jsonData.getString("checkId"));
LinkedList<HashMap<String,Object>> lastTimeList = AccessDataBaseUtil.getDataTableListKeyValue(sqlStringLastTime,"check_end_time;check_title");
JSONObject jsonobj =new JSONObject();
JSONArray jsonarray = JSONArray.fromObject(lastTimeList);
JSONObject licenseTime = jsonarray.getJSONObject(0);
jsonobj.put("licenseData", JSONArray.fromObject(list));
jsonobj.put("licenseTime", licenseTime.get("check_end_time"));
StringBuffer write = new StringBuffer();
try {
response.setHeader("Content-Disposition", "attachment;filename="+ new String((licenseTime.get("check_title").toString()+".txt").getBytes("utf-8"), "iso8859-1"));// 设置头信息
response.setContentType("application/ynd.ms-excel;charset=UTF-8");
OutputStream out = response.getOutputStream();
write.append(jsonobj);
out.write(write.toString().getBytes("UTF-8"));
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
阅读全文
0 0
- java导出Txt文件
- Java 导出txt文件
- java导出txt文件
- java导出Txt文件怎么下载
- Java导出数据到txt文件
- Java导出txt文件的方法
- java导出txt文件列对齐
- java导出txt文件列对齐
- 简单好用,java导出txt文件
- excel@txt 文件导出
- 导出到 txt 文件
- JavaScript导出txt文件
- springMVC 导出.txt文件
- Spring导出txt文件
- php导出txt文件
- 页面导出txt文件
- java 导出 txt
- java导出txt
- Uinx 时间戳的转换
- JVM学习笔记(1)----Java类的加载机制
- 【java】微信文章抓取
- Linux防火墙(iptables)的开启与关闭
- Unity 自动寻路Navmesh之跳跃,攀爬,斜坡
- java导出txt文件
- MySQL数据库优化
- 黑马程序员总结0-ubantu下linux基础&& vmware tools使用
- 构建ARM Linux交叉编译工具链 详解
- Python杂记:numpy中,"*"与dot的区别
- Tensorflow实现LSTM
- Ubuntu下解压缩文件详解及其用法
- js数组与字符串的相互转换方法
- NowCoder Wannafly 挑战赛1