我正在使用Spring mvc开发一个小的Web应用程序。我将变量放入视图中,然后从前端显示为jstl。在我的主页上,我有
function getExecJob(execid){
alert(execid);
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.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("execDetailDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","execJobDetail.action?execId="+execid,true);
xmlhttp.send();
}
execJobDetail.action 返回页面 execJobDetail.jsp,
<div id="status_code_div">
HTTP Status Code Summary <br/>
<table width="523" id="http_status_code_table">
<tr>
<th width="268" >HTTP Status Code</th>
<th width="129" ># of Urls</th>
<th width="110" >%</th>
</tr>
<c:forEach var="entry" items="${reportMap}">
<tr>
<td scope="col" class="row_type"> ${entry.key}</td>
<td scope="col" class="row_value">${entry.value}</td>
<td scope="col" class="row_value">${(entry.value)*1.0/toal}</td>
</tr>
</c:forEach>
</table>
</div>
</c:if>
但它总是返回页面,将 jstl 内容留空。谁能给我一些建议!!!谢谢!!!
如果你没有在JSP之上实际声明JSTL taglib,就会发生这种情况。这样,它不会被解析或处理,最终在生成的 HTML 输出中显示为纯文本。
将以下行添加到 JSP 的顶部,以使 JSTL 标记库运行:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
另请参阅:
- 我们的 JSTL 标签维基页面