[英]display raw xml in popup window using java when a link is clicked
I am using Struts 1.x and jsp as view to display. 我正在使用Struts 1.x和jsp作为显示视图。 Want to display the entire xml file as it is in a new pop-up window when a link is clicked in jsp.
要在单击jsp中的链接时在新的弹出窗口中显示整个xml文件。 So far I have managed to open the pop-up window but I get a blank window and save/open/cancel links in browser(IE9).
到目前为止,我已经设法打开了弹出窗口,但是我得到了一个空白窗口,并在浏览器(IE9)中保存/打开/取消了链接。 When clicking on save I get as 'url.do' but I just want to display the xml content as it is in browser, just don't want to save.
当单击保存时,我得到的是“ url.do”,但我只想显示浏览器中的xml内容,只是不想保存。
Here is what I wrote in javascript function 这是我在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";
}
Here is what I wrote in Action class 这是我在动作课上写的
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();
Try 尝试
response.setContentType("application/xml");
response.addHeader("Content-disposition", "inline");
instead. 代替。
Did you tried adding the content disposition in the response ? 您是否尝试在响应中添加内容配置?
If not try that first. 如果没有,请先尝试。 And it may be useful for you Content Disposition
这可能对您有用内容处置
Thanks for help. 感谢帮助。 Got it working.
得到它的工作。 I was forwarding to some other url in action class after writing using output stream.
使用输出流编写后,我正在转发到动作类中的其他URL。 Set the return to null and it is working fine.
将return设置为null即可正常工作。 I am able to view the xml in popup.
我能够在弹出窗口中查看xml。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.