简体   繁体   English

如何从servlet中框架重定向到主页面?

[英]How to redirect to main page with in frame from servlet?

I have 3 frames in screen , using frameset I did like this. 我在屏幕上有3帧,使用frameset我喜欢这样。

index.thml index.thml

<frameset rows="75%,25%">
    <frameset cols="20%,80%">
        <frame src="TreeGroup.jsp" name="left" id="f1"/>
        <frame src="DisplayMap.jsp"   name="top" id="f2"/>
    </frameset>
    <frame src="Tabs.jsp" name="bottom"/>
 </frameset>

in frame f1 there is a link, if I click that , it opens VehicleReg in frame f2 . 在帧f1有一个链接,如果我点击它,它VehicleReg在帧f2打开VehicleReg In frame f2 I click submit, control goes to Servlet and servlet redirect to index.html. 在框架f2我单击提交,控制转到Servlet和servlet重定向到index.html。 Here is I am facing problem , 这是我面临的问题,

In Servlet I do as response.sendRedirect("index.html") 在Servlet中我做response.sendRedirect("index.html")

but in Browser, It is already in index.html , after servlet response in frame f2 it opens index.html . 但是在浏览器中,它已经在index.html ,在帧f2 servlet响应之后它打开了index.html I mean it redirects index.html with in frame f2 . 我的意思是它在框架f2重定向index.html How to avoid this. 如何避免这种情况。 I want after servlet response a fresh index.html . 我想在servlet响应后获得一个新的index.html Can anyone help me in this please. 请有人帮我这个。

Add the following JavaScript code between the <head> tags of your index.html page. index.html页面的<head>标记之间添加以下JavaScript代码。

<script type="text/javascript" language="JavaScript">
    if (top.location != self.location) {
      top.location.href = self.location.href;
    }
</script>

This makes your index page automatically break out of the frames and reload itself. 这使您的索引页面自动脱离框架并重新加载自身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM