我使用以下代码设置请求变量 -
if (response.getEntity(String.class).equals("VALIDATED")){
System.out.println("FileUploadValidation success ");
req.setAttribute("validation", "VALIDATED");
RequestDispatcher rd = req.getRequestDispatcher("/dataloads.jsp");
rd.forward(req, res);
}else{
System.out.println("FileUploadValidation not-success ");
req.setAttribute("validation", "NOT-VALIDATED");
RequestDispatcher rd = req.getRequestDispatcher("/index.jsp");
rd.forward(req, res);
}
现在出现错误,我将请求属性设置为NOT-VALIDATED。请求被发送到index.jsp ...评估请求范围我使用jQuery显示错误消息。
现在,当我收到index.jsp的请求时,我看到"验证"属性仍然设置。
Javascript代码:
if ('${requestScope.validation}' == "NOT-VALIDATED")
{
$('#error').show()
}