发布于 2015-08-17 14:43:12 | 89 次阅读 | 评论: 0 | 来源: 网络整理

<c:catch>标记捕获发生在它的身上,并选择性地暴露任何的Throwable。只需将它用于错误处理和处理这个问题更优雅。

属性:

<c:catch>标签具有以下属性:

属性 描述 必须 默认
var 持有java.lang.Throwable,如果抛出在主体元素的变量的名称。 No None

实例:


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:catch> Tag Example</title>
</head>
<body>

<c:catch var ="catchException">
   <% int x = 5/0;%>
</c:catch>

<c:if test = "${catchException != null}">
   <p>The exception is : ${catchException} <br />
   There is an exception: ${catchException.message}</p>
</c:if>

</body>
</html>

这将产生以下结果:


The exception is : java.lang.ArithmaticException: / by zero
There is an exception: / by zero
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务