解决办法:
跳转页面前的javascript:
//预览附件
function preView() {
var keywordId=${keyword.id}+"";
$.post("${URL}/event/event!preView.action",
{kwid:keywordId},
function(data, status){
if(data == "noexists") {
alert("附件不存在,请先生成附件!");
return;
} else {
//window.open('${URL}/yq/yqPublication!preView.action?indexno='+indexno, 'newwindow', 'toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no');
//window.open('${URL}' + data, 'preViewWindow', 'toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no');
//location.href='${URL}' + data;
var isIE=!!window.ActiveXObject;
var isIE6=isIE && !window.XMLHttpRequest;
var isIE8=isIE && !!document.documentMode;
var isIE7=isIE && !isIE6 && !isIE8;
if (isIE){
if (isIE6){
window.open('${URL}' + data);
//alert("ie6");
}else if (isIE8){
window.open('event!download.action?url=' + '${URL}' + data);
//alert("ie8");
}else if (isIE7){
window.open('event!download.action?url=' + '${URL}' + data);
//alert("ie7");
} else {
window.open('${URL}' + data);
//alert("其他浏览器暂时不支持");
}
}
}
}
);
}
Action里面处理:
public String download() throws Exception {
try {
String url = Struts2Utils.getRequest().getParameter("url");
if(Validator.isNotNull(url)) {
Struts2Utils.getRequest().setAttribute("url", url);
}
//Struts2Utils.getResponse().getWriter().write("<script>location.href='event!download.action?url=" + url + "';</script>");
//Struts2Utils.getResponse().sendRedirect(url);
} catch (Exception e) {
logger.error("预览下载简报出错", e);
}
return "download";
}
返回后的页面:
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
</head>
<body>
</body>
<script type="text/javascript">
locationTo();
function locationTo() {
var urlString = location.href;
if(urlString == "" || urlString == null) {
alert("附件不存在,请重新生成!");
return;
}
var url = urlString.split("url=")[1];
window.location=url;
}
</script>
</html>