简体   繁体   English

java.lang.ArithmeticException:在displaytag中除以零

[英]java.lang.ArithmeticException: divide by zero in displaytag

I am using display tag in portals(Struts Portal Framework) deployed in websphere portal, using external paging using value list paging (implement PaginatedList) a strong exception has shown up java.lang.ArithmeticException: divide by zero in the following lines: 我在Websphere门户中部署的门户(Struts Portal Framework)中使用显示标签,使用值列表分页(实现PaginatedList)进行外部分页时, java.lang.ArithmeticException: divide by zero出现了一个强烈的异常java.lang.ArithmeticException: divide by zero在以下几行中java.lang.ArithmeticException: divide by zero

     int pageCount = behavioursPaginatedList.getFullListSize() /  Math.max(1,behavioursPaginatedList.getObjectsPerPage());
        if ((behavioursPaginatedList.getFullListSize() % behavioursPaginatedList.getObjectsPerPage()) > 0)
    {
        pageCount++;
    }


FullListSize = 13 FullListSize = 13
ObjectPerPage = 4 ObjectPerPage = 4


There are two places where divide by zero could occur: 除数可能在两个地方发生:

int pageCount = behavioursPaginatedList.getFullListSize() / 
    Math.max(1,behavioursPaginatedList.getObjectsPerPage());

In this case, Math.max(1, ...) is guaranteed to deliver a value that is non-zero. 在这种情况下, Math.max(1, ...)保证传递的值不为零。 So the exception cam't be coming from here 所以异常不会从这里来

if ((behavioursPaginatedList.getFullListSize() % 
        behavioursPaginatedList.getObjectsPerPage()) > 0)

In this case, if behavioursPaginatedList.getObjectsPerPage() returns zero, then you will get a division by zero error. 在这种情况下,如果behavioursPaginatedList.getObjectsPerPage()返回零,那么您将得到除以零的错误。


The fact that you are getting the exception says that division by zero is occurring, and that behavioursPaginatedList.getObjectsPerPage() is returning zero. 得到异常的事实表示,除以零发生 ,而且behavioursPaginatedList.getObjectsPerPage() 返回零。 You need to find out why that is happening. 您需要找出原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.ArithmeticException:除以零错误 - java.lang.ArithmeticException: divide by zero error 错误 java.lang.ArithmeticException:除以零 - Error java.lang.ArithmeticException: divide by zero java.lang.ArithmeticException:除以零 - java.lang.ArithmeticException: divide by zero java.lang.ArithmeticException:/ by零 - java.lang.ArithmeticException: / by zero 为什么我得到 java.lang.ArithmeticException:除以零 - Why am I getting java.lang.ArithmeticException: divide by zero Primefaces异常INFO:java.lang.ArithmeticException:/ by zero java.lang.ArithmeticException:/ by zero - Primefaces exception INFO: java.lang.ArithmeticException: / by zero java.lang.ArithmeticException: / by zero 为什么我收到此错误“由:java.lang.ArithmeticException:除以零”? - Why I am getting this error “Caused by: java.lang.ArithmeticException: divide by zero”? java.lang.ArithmeticException:从选择库压缩图像时除以零 - java.lang.ArithmeticException: divide by zero when compress image from pick gallery Java Applet返回“ java.lang.ArithmeticException:/零” - Java Applet Returns “java.lang.ArithmeticException: / by zero” 线程“main”中的异常 java.lang.ArithmeticException: / 为零 - Exception in thread “main” java.lang.ArithmeticException: / by zero
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM