<c:catch>, one of the most commonly used tags in jstl

a definition
This tag is used to catch exceptions thrown by tags nested within it.
 
Two actual combat
<%@ page language = "java" import = "java.util.*,com.cakin.domain.*" pageEncoding = "utf-8" %>
<!-- Introduce jstl tag library -->
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core";%>  
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" ; >
< html >
  < head >    
    < title > My JSP 'c_out.jsp' starting page </ title >
  </ head >
  < body >
    < h3 > Use of c:catch </ h3 >
         < c:catch var = "myexception" >
                 <%
                         int i = 8/0;
                 %>
         </ c:catch >
         < c:out value = " ${myexception} " ></ c:out >
  </ body >
</ html >
 
Three test results

 



 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326608152&siteId=291194637