How to catch java.lang.NumberFormatException.forInputString Exception in Controller?

前端 未结 1 1383
温柔的废话
温柔的废话 2021-01-15 03:33

I have a checkbox in my JSP page that accepts integer values:

 Dangerous Checkbox 
相关标签:
1条回答
  • 2021-01-15 04:03

    you can use JSTL's c:catch tag:

    <c:catch var ="numberFormatException">
    <form:checkbox path="somePath" value="blah" /> Dangerous Checkbox <br />
    </c:catch>
    
    <c:if test = "${numberFormatException!= null}">
       <p>The exception is : ${numberFormatException} <br />
       There is an exception: ${numberFormatException.message}</p>
    </c:if>
    
    0 讨论(0)
提交回复
热议问题