[英]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.