有时有这种情况,在父页面新开了一个窗口,然后当关闭新窗口时在此刷新父窗口。
/**
* 输出JS,关闭当前窗口,并刷新父窗口
*
* @throws Exception
*/
public void closeRefreshWindow() {
PrintWriter pw = null;
try {
pw = ServletActionContext.getResponse().getWriter();
pw.write("<script type=\"text/javascript\">try{window.opener.location.reload();window.close();}catch(e){window.close();}</script>");
pw.flush();
} catch (IOException e) {
try{
if(pw != null){
pw.write("<script type=\"text/javascript\">window.close();</script>");
pw.flush();
}
}catch(Exception el){
}
}finally{
if(pw != null){
pw.close();
}
}
}
/**
* 输出JS,刷新顶级窗口
*
* @throws Exception
*/
public void refreshTopWindow() {
PrintWriter pw = null;
try {
pw = ServletActionContext.getResponse().getWriter();
pw.write("<script type=\"text/javascript\">top.document.location.href=top.document.location.href;</script>");
pw.flush();
pw.close();
} catch (IOException e) {
log.error("输出JS,刷新顶级窗口时,出现异常!", e);
//throw new SystemException(e);
}finally{
if(pw != null){
pw.close();
}
}
}
在子页面操作完后调用上面的方法就可以了。@_@祝:学习愉快
5272

被折叠的 条评论
为什么被折叠?



