<: Captura C> etiqueta
<C: catch> se utiliza principalmente para el tratamiento de condiciones anormales que producen el error y el mensaje de error se almacena.
sintaxis
<c:catch var="<string>"> ... </c:catch>
propiedad
<C: catch> tiene los siguientes atributos:
propiedad | descripción | Si es necesario | defecto |
---|---|---|---|
var | Las variables utilizadas para almacenar el mensaje de error | no | ninguno |
Los ejemplos de demostración
<%@ 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>
Los ejemplos de los resultados operativos de arriba:
异常为 : java.lang.ArithmeticException: / by zero 发生了异常: / by zero