简体   繁体   English

单击链接时,使用java在弹出窗口中显示原始xml

[英]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.

相关问题 单击按钮并重定向到父窗口时显示状态弹出窗口-SpringBoot - Display a status popup when a button is clicked and redirect to the parent window - SpringBoot 在WebDynpro Java中的弹出窗口中显示选定的行 - Display selected row in a popup window in WebDynpro Java 在 WebView android 中点击链接显示 pdf - Display pdf when link clicked in WebView android 如何使用Java在弹出窗口中显示数组列表的输出? - How can I display the output of an array list in a popup window using Java? 单击按钮时,android在屏幕上显示文本。 xml + Java关系 - android display text on screen when button is clicked. xml + java relationship 在Java中单击时更改链接的颜色 - change color of link when clicked in Java 将活动显示为弹出窗口 window - Display activity as a popup window 如何在提交表单时关闭弹出窗口时重新加载父窗口,而我正在使用java类显示子窗口内容 - how to reload the parent window while closing popup window when on form submission i am using java class to show the child window content 使用 java 链接 XML 和 XSD - Link XML and XSD using java 单击按钮后在弹出窗口中显示图像-Android / Java - Display image in popout window after button is clicked — Android/Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM