<C: cattura> tag
<C: cattura> tag viene utilizzato principalmente per il trattamento di condizioni anomale che hanno prodotto l'errore e il messaggio di errore viene memorizzato.
sintassi
<c:catch var="<string>"> ... </c:catch>
proprietà
<C: cattura> tag ha i seguenti attributi:
proprietà | descrizione | Se necessario | difetto |
---|---|---|---|
var | Le variabili utilizzate per memorizzare il messaggio di errore | no | nessuno |
Esempi Demo
<%@ 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>
Esempi dei risultati operativi di cui sopra:
异常为 : java.lang.ArithmeticException: / by zero 发生了异常: / by zero