方法 A:在父页面加<meta>标签
<head> <meta http-equiv="Connection" content="close"> </head>⚠️ 这个 meta 标签会被浏览器忽略——HTTP/1.1 规范不允许用 meta 控制 Connection 头。
方法 B:在父页面用 JavaScript 动态创建 iframe
<iframe id="myFrame"></iframe> <script> // 创建 iframe 时设置 fetchpriority 或 connection var iframe = document.getElementById('myFrame'); iframe.onload = function() { // iframe 加载后强制关闭 keep-alive(但这做不到) }; // 用 fetch API 替代 iframe(推荐) fetch('/your-context/test.jsp') .then(response => response.text()) .then(html => { // 把 HTML 注入页面 }); </script>方法 C:用 XHR 替代 iframe(最稳)
<div id="photoContainer"></div> <script> var xhr = new XMLHttpRequest(); xhr.open('GET', '/your-context/test.jsp', true); xhr.onload = function() { if (xhr.status === 200) { document.getElementById('photoContainer').innerHTML = xhr.responseText; } }; xhr.send(); </script>XHR 默认不带 keep-alive(取决于浏览器实现)——可以绕过 WebLogic 的 keep-alive bug。