[英]how to get custom exception message in ajaxError of jquery
I know we can get exception using xhr.responseText
, but in my APP, the responseText
display as exception description amended by Tomcat. 我知道我们可以使用xhr.responseText
获得异常,但是在我的APP中, responseText
显示为由Tomcat修改的异常描述。 please refer to below image, is there anyone can tell me how can I control the content of responseText
or how to handle custom message(may be in a better way). 请参考下图,有没有人可以告诉我如何控制responseText
的内容或如何处理自定义消息(可能会更好)。 I need a title and content in the response as I can display them in dialog of Jquery UI. 我需要在响应中添加标题和内容,因为我可以在Jquery UI对话框中显示它们。 BTW, I throw a general exception just like throw new Exception("some error happens");
顺便说一句,我抛出一个一般异常,就像throw new Exception("some error happens");
You can define custom error message in your web.xml
like this - 您可以像这样在web.xml
定义自定义错误消息-
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/Error.jsp</location>
</error-page>
You can have any text in your error.jsp page, that text will be sent to client on respective error 您可以在error.jsp页面中包含任何文本,该文本将根据相应的错误发送给客户端
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.