js转到action后再转的的页面自动关闭!怎么回事

Wilsun_BL 2013-10-22 09:58:19
js

function showdelete(e){

var ids = e.parentNode.parentNode.getElementsByTagName('td')[1].innerHTML;

window.location.href="clients!delete.action?ids="+ids;
}


action

public String delete(){
System.out.println("delete++");
int flag = clientdao.delete(ids);

if(flag==1)
msg = "删除成功 !";
else
msg = "删除失败!";
ActionContext.getContext().put("msg", msg);

return "deletes";

}

执行完 delete后 会跳转到一个jsp 但是那个jsp 会瞬间被刷新 怎么回事?
页面更简单 就是输出一句话 但是 那个页面会瞬间被关闭 !怎么回事?
...全文
239 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wilsun_BL 2013-10-23
  • 打赏
  • 举报
回复
已经解决了 window.location.href 失效的解决办法 window.location.href 有时会失效..这又是万恶的IE的BUG.. 微软上公布3个解决方案的. 原文地址:http://support.microsoft.com/kb/190244/en-us 第一种: 在window.location.href 后面加上 window.event.returnValue = false; 如: <a href="#" onclick="window.location.href='http://www.microsoft.com'; window.event.returnValue=false;"> 第二种: 把window.location.href写成 JavaScript:window.location.href 如: <a href="JavaScript:window.location.href='http://www.microsoft.com';"> 第三种: 不写 href 直接写onlick .然后通过css样式来控制鼠标移上去显示手型效果. 如: <a onclick="window.location.href='http://www.microsoft.com';" onmouseover="window.status='http://www.microsoft.com';" onmouseout="window.status='';" style="cursor:pointer; text-decoration:underline; color:blue; font-family:times new roman">
快乐的小呆 2013-10-22
  • 打赏
  • 举报
回复
页面代码也贴一下
Wilsun_BL 2013-10-22
  • 打赏
  • 举报
回复
引用 1 楼 l568646976 的回复:
struts配置文件贴一下
  
	  <action name="clients" class="ClientAction" >
	  	<result name="success">/MyJsp.jsp</result>
	  	<result name="input">/MyJsp.jsp</result> 
	  	<result name="showupdates">/updateClient.jsp</result>
	  	<result name="update">/MyJsp.jsp</result>
	  	<result name="deletes">/its.jsp</result>
	  </action>
快乐的小呆 2013-10-22
  • 打赏
  • 举报
回复
struts配置文件贴一下
对java有感觉 2013-10-22
  • 打赏
  • 举报
回复
window.location.href="clients!delete.action?ids="+ids; 加上项目名看看。
对java有感觉 2013-10-22
  • 打赏
  • 举报
回复
要不先屏蔽掉ActionContext.getContext().put("msg", msg);看还会不会关闭。
对java有感觉 2013-10-22
  • 打赏
  • 举报
回复
ActionContext.getContext().put("msg", msg);最可疑就是这个方法了 这个是干什么用的。是推送消息的吗?看看这个方法。
Wilsun_BL 2013-10-22
  • 打赏
  • 举报
回复
引用 5 楼 defonds 的回复:
[quote=引用 4 楼 u012447444 的回复:] [quote=引用 3 楼 l568646976 的回复:] 页面代码也贴一下

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>My JSP 'its.jsp' starting page</title>
    
	<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 rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
 
  <body>
  <%System.out.println("its.jsp"); %>
    This is my JSP page. <br>
  </body>
</html>
[/quote]这个会瞬间关闭?[/quote] 嗯 是的 会有 非常短暂的显示 几乎肉眼看不见 但是js中的 <%System.out.println("its.jsp"); %>执行了
快乐的小呆 2013-10-22
  • 打赏
  • 举报
回复
暂时没发现有什么可以使你页面刷新一次 然后突然关闭的原因。。
Defonds 2013-10-22
  • 打赏
  • 举报
回复
引用 4 楼 u012447444 的回复:
[quote=引用 3 楼 l568646976 的回复:] 页面代码也贴一下

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>My JSP 'its.jsp' starting page</title>
    
	<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 rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
 
  <body>
  <%System.out.println("its.jsp"); %>
    This is my JSP page. <br>
  </body>
</html>
[/quote]这个会瞬间关闭?
Wilsun_BL 2013-10-22
  • 打赏
  • 举报
回复
引用 3 楼 l568646976 的回复:
页面代码也贴一下

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>My JSP 'its.jsp' starting page</title>
    
	<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 rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
 
  <body>
  <%System.out.println("its.jsp"); %>
    This is my JSP page. <br>
  </body>
</html>

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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