对IFrame,如何使mapping.findForward指向的页面成为当前主页面?

eHuaTian 2009-04-13 04:21:02
主页面内嵌入一个IFrame,IFrame内有一个按钮,点击此按钮,执行Struts的一个Action,Action执行完成后使用mapping.findForward进入一个新的页面。如果不作处理,进入的新页面仍处于IFrame内,主页面的其他区域内容仍在当前页面上,没有变化。现在要使mapping.findForward所指向的页面成为当前主页面,如何做呢?
...全文
217 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovingpig 2009-04-14
  • 打赏
  • 举报
回复
在你的页面上加上
<script>
window.name="mywindow";
</script>

你iframe里面也肯定是用form递交的吧
只要在那个form上再加一个属性 target

<form action="" method="post" target="mywindow">
</form>

这样在你这个form递交的时候就会刷新名称为mywindow的窗口
lovingpig 2009-04-14
  • 打赏
  • 举报
回复
晕 不知道你怎么试的

我这边有个例子
你看下:
iframe.jsp
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" href="<%=basePath%>css/homefinancial.css" type="text/css">
<script src="<%=basePath%>include/homeFinancial.js" language="javascript"></script>
<html:form action="addConsumeAction.do?method=add" method="post" target="mainwindow">
<table>
<tr><td>Consumer: </td><td><html:text property="name"></html:text></td></tr>
<tr><td>amount: </td><td><html:text property="amount"></html:text></td></tr>
<tr><td>Description: </td><td><html:text property="description"></html:text></td></tr>
<tr><td>Date: </td><td><html:text property="date"></html:text></td></tr>
<tr><td><input type="button" value="add" onclick="addConsumeFormSubmit();"></input></td></tr>
</table>
</html:form>


homeFinancial.jsp

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="spring" uri="/spring" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><fmt:message key="login.title"/></title>
</head>
<link rel="stylesheet" href="<%=basePath%>css/homefinancial.css" type="text/css">
<script src="<%=basePath%>include/homeFinancial.js" language="javascript"></script>
<script>
window.name="mainwindow";
</script>

<body>

<h1>Successful</h1>

<logic:notEmpty name="consumes">
<table border="0" cellspacing="0" cellpadding="0" class="mytable" id="tableForRecValue">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Amount</th>
<th>Description</th>
<th>Date</th>
</tr>
</thead>
<c:forEach items="${consumes}" var="consume" varStatus="status">
<tr>
<td><c:out value="${status.index + 1}"/></td>
<td><c:out value="${consume.name}"/></td>
<td><c:out value="${consume.number}"/></td>
<td><c:out value="${consume.description}"/></td>
<td><c:out value="${consume.date}"/></td>
</tr>
</c:forEach>
</table>
<table>
<c:if test="${pageNumber > 1}">
<tr>
<td><c:out value="${currentPage}"/>/<c:out value="${pageNumber}"/></td>
<c:if test="${currentPage > 1}">
<td><a href="homeFinancialAction.do?method=list&page=<c:out value="${prePage}"/>">pre</a></td>
</c:if>
<c:if test="${currentPage < pageNumber}">
<td><a href="homeFinancialAction.do?method=list&page=<c:out value="${nextPage}"/>">next</a></td>
</c:if>
</tr>
</c:if>
</table>
</logic:notEmpty>
<logic:empty name="consumes">
<table>
<tr><td><fmt:message key="homefinancial.no.consume"/></td></tr>
</table>
</logic:empty>
<IFRAME name="iframe" SCROLLING="yes" src="jsp/iframe.jsp" width="100%" height="100%" id="page2"></IFRAME>

</body>
</html>
eHuaTian 2009-04-14
  • 打赏
  • 举报
回复
谢谢!能不能来段完整的代码好参考一下。我是刚学jsp
eHuaTian 2009-04-14
  • 打赏
  • 举报
回复
谢谢lovingpig等的回答。我按lovingpig的方法试过,还是不行丫。Action的mapping.findForward所指向的页面仍然在IFrame内。现在要使mapping.findForward所指向的页面为当前主页面,有没有其他计算方法了?
lovingpig 2009-04-13
  • 打赏
  • 举报
回复
你在主页面上用javascript设置 窗口名称
window.name="mywindow";

再把你的form中的target 设置成 mywindow

<form action="" target="mywindow">
</form>
数据名称:337个城市智慧健康养老DID数据(2017-2025) 数据范围:31省 数据来源:工信部 数据注意:智慧健康养老是以智能硬件、数字化服务平台为载体,融合物联网、大数据、云计算、AI 等信息技术,围绕老年人健康管护、日常养老两大需求形成的新型产业与服务体系;核心是把健康管理、安全监护、生活照料、医疗康复、精神慰藉打通,实现医养结合、居家 - 社区 - 机构一体化,缓解老龄化与护理人力缺口压力 数据指标:city、year、treat Python 数据分析完整实操流程 整体分为 6 大步骤:数据读取 → 数据清洗(最耗时)→ 描述性统计探索 → 可视化分析 → 深度挖掘(相关性、分组、回归等)→ 结果导出 常用工具库: 数据读写、表格处理:pandas 数值计算:numpy 绘图可视化:matplotlib、seaborn 高级统计 / 机器学习:scipy、scikit-learn 我国智慧健康养老产业持续深化落地,各地依托数字技术、智能终端、大数据平台,逐步构建起机构、社区、居家三位一体的智慧养老服务体系,数字化赋能养老服务转型升级成效持续显现。 全国多地持续推进智慧养老院建设、居家养老智能设备布设、养老服务数字化平台搭建,逐步实现养老服务精准化、监管智能化、供给多元化。 各地积极探索养老数据资源化利用、医养智慧融合、适老科技产品落地应用,形成了一批可复制、可推广的城市智慧养老发展模式。

67,535

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧