我在做一些JSP标记。我将一个类型参数传递给标签。当属性无效时,我可以在自定义JSP标记中使用JSTL抛出异常吗?
的代码如下所示:
<%@ 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中抛出一个正常的异常吗?
我不认为你真的需要在用户界面中引发异常。只要在其他块中加入错误描述即可。 – adatapost 2012-01-13 04:29:44
谁会接受这个例外? – skaffman 2012-01-13 09:24:14
只需立即注意问题 – 2012-01-13 10:23:15