如果您有任何代码段,请发帖吗? 发送电子邮件时,收件箱应该有jsp页面。任何代码片段?
答案 0 :(得分:0)
由于jsp / servlet / chain可以添加动态内容,唯一真正的方法是使用以下内容从URL中获取结果HTML:
URL url = new URL("http://www.oracle.com/");
byte[] html;
try (InputStream in = new BufferedInputStream(url.openStream());
ByteArrayOutputStream bout = new ByteArrayOutputStream();) {
byte[] buffer = new byte[512];
int read = 0;
while ((read = in.read(buffer)) != -1) {
bout.write(buffer, 0, read);
}
html = bout.getBytes();
}
如果您希望将HTML作为字符串:
String htmlString = new String(html, StandardCharset.UTF-8);