如何在java中实现自动生成html

2020-06-17 母婴育儿 75阅读
创建一个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("");
sb.append("");
sb.append("每日运营报表<&>"); <br>sb.append("<meta http-equiv='\"Content-Type\"' content='\"text/html;' charset='utf-8\"' &>"); <br>sb.append("<style type='\"text/css\"'>"); <br />sb.append("TABLE{border-collapse:collapse;border-left:solid 1 #000000; border-top:solid 1 #000000;padding:5px;}"); <br />sb.append("TH{border-right:solid 1 #000000;border-bottom:solid 1 #000000;}"); <br />sb.append("TD{font:normal;border-right:solid 1 #000000;border-bottom:solid 1 #000000;}"); <br />sb.append("</style></head>"); <br />sb.append("<body bgcolor=\"#FFF8DC\">"); <br />sb.append("<div align=\"center\">"); <br />sb.append("<br/>"); <br />sb.append("<br/>"); <br />List<Map<String, Object>> result1 = getRpt(sqlProperties <br />.getProperty("sql1")); <br />for (Map.Entry<String, Object> m : result1.get(0).entrySet()) { <br />sb.append(fileProperties.getProperty("file1")); <br />sb.append(m.getValue()); <br />} <br />sb.append("<br/><br/>"); <br />输出<br />sb.append("</div></body></html>"); <br />printStream.println(sb.toString());</style></&>
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com