【发布时间】:2012-02-09 09:06:56
【问题描述】:
我正在制作一些 JSP 标记。我将类型参数传递给标签。
代码如下:
<%@ attribute name="type" require="true" %>
<c:choose>
<c:when test="${type eq 'even'}">
<c:set var="remainder" value="0" />
</c:when>
<c:when test="${type eq 'odd'}">
<c:set var="remainder" value="1" />
</c:when>
<c:otherwise>
<%-- Want to throw exception!! --%>
</c:otherwise>
</c:choose>
如果我传递了错误的值,我想抛出一个异常。当我搜索这个主题时,我发现了this。我不能在 JSTL 中抛出一个正常的异常吗?
【问题讨论】:
-
我不认为你真的需要在用户界面中抛出异常。只需将错误描述放在 else 块中即可。
-
谁会捕捉到这个异常?
-
只要扔就马上注意到问题
标签: jsp exception jstl custom-tags