문제

I'm implementing a simple JSP page using JSTL 1.2 (Apache Taglibs). The page does the following:

        <c:catch var="error">
            <fmt:parseNumber var="parsedNum" value="${param.num}" />
        </c:catch>

The HTML input element looks like this:

    <input type="text" name="num" size="3"/>

I'm aware that the input "12a" is permitted due to the way the parsing mechanism works. Nevertheless, I would like to catch completely wrong input, e.g., "aaa". Unfortunately, the thrown exception is not managed by <c:catch>, resulting in Tomcat 7 showing the whole stack trace.

Any advice? Thanks.

도움이 되었습니까?

해결책

Please post a testable page for us. For example, the following page works fine for me.

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:catch var="error">
<fmt:parseNumber var="parsedNum" value="aaa" />
</c:catch>
${parsedNum}
${error}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top