我试图通过POST请求发送HTML内容,但未使用Chrome在服务器端发送。在使用Mozilla时,我在jsp中获取请求数据。 当HTML内容很小时,这适用于两种浏览器。我使用Apache FOP生成带有HTML内容的PDF。无法在Chrome上将大型HTML内容发布到服务器上
var iframe = document.createElement('iframe');
iframe.setAttribute('name','eyeframe');
document.body.appendChild(iframe);
var myform = document.createElement('form');
document.body.appendChild(myform);
myform.setAttribute('action','myJspToRenderHtmlAsPdf.jsp');
myform.setAttribute('method','post');
myform.setAttribute('target','eyeframe');
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "htmlContent");
hiddenField.setAttribute("value", strHTML);
myform.appendChild(hiddenField);
myform.submit();
我将HTML分成块并发布它们并将它们重新加入到jsp中。这种做法的方法也失败与铬和ie。
代替发送整个html,发送生成此html的URL。所以服务器把它并转换为PDF。 – rogeriolino 2015-04-01 13:13:52
我实际上是在javascript本身生成HTML文本(XSLT转换)。 – 2015-04-01 13:32:34