【发布时间】:2014-02-14 05:30:02
【问题描述】:
我正在尝试来自 jsp 页面的 ajax 调用,如下所示,
<head>
<script>
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "ajax_info.txt", true);
xmlhttp.send();
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
</script>
</head>
<body>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
这里第一次调用 servlet 过滤器,但在 ajax 调用期间我看不到调用 doFilter。
过滤器的 url-mapping 被映射到服务器的所有传入请求为 *。
为什么这里没有为 Ajax 调用调用 Servlet 过滤器?
【问题讨论】:
-
xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } } 尝试从内部就绪状态更改写入响应文本
标签: java javascript jquery ajax servlets