![](/img/trans.png)
[英]Display a status popup when a button is clicked and redirect to the parent window - SpringBoot
[英]display raw xml in popup window using java when a link is clicked
我正在使用Struts 1.x和jsp作为显示视图。 要在单击jsp中的链接时在新的弹出窗口中显示整个xml文件。 到目前为止,我已经设法打开了弹出窗口,但是我得到了一个空白窗口,并在浏览器(IE9)中保存/打开/取消了链接。 当单击保存时,我得到的是“ url.do”,但我只想显示浏览器中的xml内容,只是不想保存。
这是我在javascript函数中写的
function viewXML(bcFileNo){
popupwin = window.open("about:blank", "popupwin", "toolbar=no, resizable=yes, menubar=no, scrollbars=yes, status=no, location=no, width=900 , height=400");
var form = document.forms['BirthCertificateForm'];
form.action = "/Vista-Web/birthCertificateOverview.do?method=viewBirthCertificateDetails&bCertFileNo="+bcFileNo;
form.target = "popupwin";
form.submit();
form.target = "_self";
}
这是我在动作课上写的
String xmlContent = getXMLContent();
byte[] birthCertBytes = xmlContent.getBytes();
// set xml content
response.setContentType("html/xml");
// write the content to the output stream
BufferedOutputStream outStream = new BufferedOutputStream(response.getOutputStream());
outStream.write(birthCertBytes);
outStream.flush();
outStream.close();
尝试
response.setContentType("application/xml");
response.addHeader("Content-disposition", "inline");
代替。
您是否尝试在响应中添加内容配置?
如果没有,请先尝试。 这可能对您有用内容处置
感谢帮助。 得到它的工作。 使用输出流编写后,我正在转发到动作类中的其他URL。 将return设置为null即可正常工作。 我能够在弹出窗口中查看xml。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.