我想加载我的Error.jsp
in my ErrorDiv
if Action
类返回错误。我正在执行 AJAX 调用。
JS:
success: function(result){
if(result === 'success')
alert('Database Updated Successfully!');
else{
$('#ErrorDiv').load('/gma/pages/Error.jsp');
}
}
Error.jsp
:
<body>
<%
request.setAttribute("decorator", "none");
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<s:if test="hasActionErrors()">
<s:actionerror />
</s:if>
</body>
但是,不会显示操作错误。在我检查的萤火虫中,响应GET
Error.jsp
在那<body> </body>
部分变空。
Why are actionError
没有显示?
EDIT:
动作类:
try{
slsConfigureTspThresholdRemote.setThresholdParameters(circleId, tspId, thresholdTypeFlag, thresholdParametersList);
}
catch (Exception e){
addActionError(e.getMessage());
e.printStackTrace();
result = "error";
return ERROR;
}
struts.xml:
<action name="updateThresholdParameters"
class="cdot.oss.cmsat.gma.struts.ConfigureTspThresholdAction" method="updateThresholdParameters">
<result name="success" type="json">
<param name="root">result</param>
</result>
<result name="error">pages/Error.jsp</result>
目前,我正在做$('#ErrorDiv').html(result);
这样我的 JSP 就可以加载了div
代替
$('#ErrorDiv').load('/gma/pages/Error.jsp');!