How to get static method value in jsp without crea

2019-07-30 03:14发布

问题:

Below code for bytes to kb conversion code its for Static return type.So how can i get a value in many jsp without creation bean.

public static double bytesToKB(int bytes){
  return (double)bytes/1024;
}

回答1:

how about this?

<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<spring:eval expression="T(com.abc.xyz.YourClassName).bytesToKB(2560)" var="result"></spring:eval>
Spring Eval result: <c:out value="${result }"/>