Latest web development tutorials

<C : 캐치> 태그

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리

<C : 캐치> 태그는 주로 오류를 생성 비정상적인 질환을 치료하는 데 사용되어, 에러 메시지가 저장된다.

구문

<c:catch var="<string>">
...
</c:catch>

재산

<C : 캐치> 태그는 다음과 같은 특성이 있습니다 :

재산 기술 필요한 경우 디폴트 값
VAR 변수는 오류 메시지를 저장하기 위해 사용 아니 없음

예를 들면 데모

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:catch 标签实例</title>
</head>
<body>

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

<c:if test = "${catchException != null}">
   <p>异常为 : ${catchException} <br />
   发生了异常: ${catchException.message}</p>
</c:if>

</body>
</html>

상기 동작 결과의 예 :

异常为 : java.lang.ArithmeticException: / by zero 
发生了异常: / by zero

JSP 표준 태그 라이브러리 JSP 표준 태그 라이브러리