속성
| 속성 | 설명 | 필수 | 기본값 |
|---|---|---|---|
| var | 본문에 있는 요소에 의해 throw된 경우 java.lang.Throwable을 보유할 변수의 이름입니다. | 아니요 | 없음 |
예시
<%@ taglib uri = "https://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