怎样让JSP提交表单后不跳转到action,页面停留本页面 20
我用了添加表单target属性的方法,添加了空框架,这样就阻止了页面跳转,但是添加页面上的返回键居然不能返回上一页,按返回键同样弹出添加成功的提示框。帮我把返回键功能恢复...
我用了添加表单target属性的方法,添加了空框架,这样就阻止了页面跳转,但是添加页面上的返回键居然不能返回上一页,按返回键同样弹出添加成功的提示框。帮我把返回键功能恢复正常。
JSP代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<%=path %>/css/Common.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/css/sitegeneric08.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function check()
{
}
</script>
</head>
<body onload="init()">
<div class="NewContainer770">
<div class="BoxHeader">
<div class="BoxHeader-center MarginTop10">录入班级信息</div>
</div>
<div class="Slot">
<form action="<%=path %>/banjiAdd.action" name="form1" method="post" target="actionframe">
<table align="left" border="0">
<iframe width="0" height="0" name="actionframe"></iframe>
<tr>
<td align="center">班级编号:</td>
<td><input name="banjiBianhao" type="text" maxlength="12"/></td>
</tr>
<tr>
<td align="center">班级名称:</td>
<td><input type="text" name="banjiName" maxlength="15"/></td>
</tr>
<tr>
<td align="center">入学年份:</td>
<td><input class="Wdate" readonly="true" type="text" id="banjiRuxuenianfen" name="banjiRuxuenianfen" onfocus="new WdatePicker(this)"/></td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="zhuanyeId" value="<%=request.getParameter("zhuanyeId") %>">
<input type="submit" value="确定""/>
<input type="reset" value="重置"/>
<input type="button" onclick="javascript:history.go(-1);" value="返回"/>
<font color="red"></font>
</td>
</tr>
<tr height="30">
</tr>
</table>
</form>
<ul>
<li><a href="" title=""> </a> </li>
<li><a href="" title=""> </a> </li>
</ul>
</div>
</div>
</body>
</html>
banjiAdd.action的代码
public String banjiAdd()
{
TBanji banji=new TBanji();
banji.setBanjiBianhao(banjiBianhao);
banji.setBanjiName(banjiName);
banji.setBanjiRuxuenianfen(banjiRuxuenianfen);
banji.setBanjiDel("no");
banji.setZhuanyeId(zhuanyeId);
TZhuanye zhuanye=zhuanyeDAO.findById(zhuanyeId);
TXibie xibie=xibieDAO.findById(zhuanye.getXibieId());
banji.setXibieId(zhuanye.getXibieId());
banji.setXuyuanId(xibie.getXuyuanId());
banjiDAO.save(banji);
this.setMessage("添加成功");
this.setPath("xuyuanMana.action");
return "succeed";
} 展开
JSP代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<%=path %>/css/Common.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/css/sitegeneric08.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function check()
{
}
</script>
</head>
<body onload="init()">
<div class="NewContainer770">
<div class="BoxHeader">
<div class="BoxHeader-center MarginTop10">录入班级信息</div>
</div>
<div class="Slot">
<form action="<%=path %>/banjiAdd.action" name="form1" method="post" target="actionframe">
<table align="left" border="0">
<iframe width="0" height="0" name="actionframe"></iframe>
<tr>
<td align="center">班级编号:</td>
<td><input name="banjiBianhao" type="text" maxlength="12"/></td>
</tr>
<tr>
<td align="center">班级名称:</td>
<td><input type="text" name="banjiName" maxlength="15"/></td>
</tr>
<tr>
<td align="center">入学年份:</td>
<td><input class="Wdate" readonly="true" type="text" id="banjiRuxuenianfen" name="banjiRuxuenianfen" onfocus="new WdatePicker(this)"/></td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="zhuanyeId" value="<%=request.getParameter("zhuanyeId") %>">
<input type="submit" value="确定""/>
<input type="reset" value="重置"/>
<input type="button" onclick="javascript:history.go(-1);" value="返回"/>
<font color="red"></font>
</td>
</tr>
<tr height="30">
</tr>
</table>
</form>
<ul>
<li><a href="" title=""> </a> </li>
<li><a href="" title=""> </a> </li>
</ul>
</div>
</div>
</body>
</html>
banjiAdd.action的代码
public String banjiAdd()
{
TBanji banji=new TBanji();
banji.setBanjiBianhao(banjiBianhao);
banji.setBanjiName(banjiName);
banji.setBanjiRuxuenianfen(banjiRuxuenianfen);
banji.setBanjiDel("no");
banji.setZhuanyeId(zhuanyeId);
TZhuanye zhuanye=zhuanyeDAO.findById(zhuanyeId);
TXibie xibie=xibieDAO.findById(zhuanye.getXibieId());
banji.setXibieId(zhuanye.getXibieId());
banji.setXuyuanId(xibie.getXuyuanId());
banjiDAO.save(banji);
this.setMessage("添加成功");
this.setPath("xuyuanMana.action");
return "succeed";
} 展开
4个回答
展开全部
页面停留本页面 action为空不就好了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用ajax提交表单,如果提交成功返回成功!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
推荐在返回键上添加事件,点击跳到你想要的地方
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询