如何用java代码在本地硬盘里生成一个html页面
2个回答
2017-05-12 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
创建一个StringBuilder对象,通过append方法来为其添加html语句。
StringBuilder sb = new StringBuilder();
Properties fileProperties = getProperties("file");
Properties sqlProperties = getProperties("sql");
PrintStream printStream = new PrintStream(new FileOutputStream(
"report.html"));
sb.append("<html>");
sb.append("<head>");
sb.append("<title>每日运营报表</title>");
sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
sb.append("<style type=\"text/css\">");
sb.append("TABLE{border-collapse:collapse;border-left:solid 1 #000000; border-top:solid 1 #000000;padding:5px;}");
sb.append("TH{border-right:solid 1 #000000;border-bottom:solid 1 #000000;}");
sb.append("TD{font:normal;border-right:solid 1 #000000;border-bottom:solid 1 #000000;}");
sb.append("</style></head>");
sb.append("<body bgcolor=\"#FFF8DC\">");
sb.append("<div align=\"center\">");
sb.append("<br/>");
sb.append("<br/>");
List<Map<String, Object>> result1 = getRpt(sqlProperties
.getProperty("sql1"));
for (Map.Entry<String, Object> m : result1.get(0).entrySet()) {
sb.append(fileProperties.getProperty("file1"));
sb.append(m.getValue());
}
sb.append("<br/><br/>");
输出
sb.append("</div></body></html>");
printStream.println(sb.toString());
StringBuilder sb = new StringBuilder();
Properties fileProperties = getProperties("file");
Properties sqlProperties = getProperties("sql");
PrintStream printStream = new PrintStream(new FileOutputStream(
"report.html"));
sb.append("<html>");
sb.append("<head>");
sb.append("<title>每日运营报表</title>");
sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
sb.append("<style type=\"text/css\">");
sb.append("TABLE{border-collapse:collapse;border-left:solid 1 #000000; border-top:solid 1 #000000;padding:5px;}");
sb.append("TH{border-right:solid 1 #000000;border-bottom:solid 1 #000000;}");
sb.append("TD{font:normal;border-right:solid 1 #000000;border-bottom:solid 1 #000000;}");
sb.append("</style></head>");
sb.append("<body bgcolor=\"#FFF8DC\">");
sb.append("<div align=\"center\">");
sb.append("<br/>");
sb.append("<br/>");
List<Map<String, Object>> result1 = getRpt(sqlProperties
.getProperty("sql1"));
for (Map.Entry<String, Object> m : result1.get(0).entrySet()) {
sb.append(fileProperties.getProperty("file1"));
sb.append(m.getValue());
}
sb.append("<br/><br/>");
输出
sb.append("</div></body></html>");
printStream.println(sb.toString());
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询