小白教程
所有教程
关于
Search
172.70.100.205
172.70.100.205
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Jstl core catch tag”的源代码
本页内容
上一节:
Jstl_core_remove_tag
下一节:
Jstl_core_if_tag
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:<c:catch>}}[[Category:jsp jstl|4]] = <c:catch> 标签 = [[jsp jstl|JSP 标准标签库]] <c:catch> 标签主要用来处理产生错误的异常状况,并且将错误信息储存起来。 === 语法格式 === <sample title="" desc="" lang="jsp" hererun="1"> <c:catch var="<string>"> ... </c:catch> </sample> === 属性 === <c:catch>标签有如下属性: {| class="table table-striped table-hover" ! 属性 ! 描述 ! 是否必要 ! 默认值 |- | var | 用来储存错误信息的变量 | 否 | None |} == 实例演示 == <sample title="" desc="" lang="jsp" hererun="1"> <%@ 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> </sample> 以上实例运行结果: <sample title="" desc="" lang="jsp" hererun="1"> 异常为 : java.lang.ArithmeticException: / by zero 发生了异常: / by zero </sample> [[jsp jstl|JSP 标准标签库]]
返回至“
Jstl core catch tag
”。
上一节:
Jstl_core_remove_tag
下一节:
Jstl_core_if_tag