Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在jstl中调用静态方法?_Java_Jstl_Static Methods_Taglib - Fatal编程技术网

Java 如何在jstl中调用静态方法?

Java 如何在jstl中调用静态方法?,java,jstl,static-methods,taglib,Java,Jstl,Static Methods,Taglib,我已经看到这个问题在这里得到了回答,但当我尝试同样的方法时,它没有起作用。这是我的密码: package linear_programming.matrix; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.text.NumberFormat; /** * * @author Jevison7x */ public final class MatrixOperations<T

我已经看到这个问题在这里得到了回答,但当我尝试同样的方法时,它没有起作用。这是我的密码:

package linear_programming.matrix;

import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 *
 * @author Jevison7x
 */
public final class MatrixOperations<T extends Number>
{
    /**
 * This method round's off decimal numbers to two decimal places.
 * @param d The decimal number to be rounded off.
     * @param decPlaces The number of decimal places to round off.
 * @return the rounded off decimal number.
 */
public static double roundOff(double d, int decPlaces)
{ 
        if(decPlaces < 0)
            throw new IllegalArgumentException("The number of decimal places cannot be less than 0.");
        else
        {
            String places = "";
            for(int i = 0; i < decPlaces; i++)
            places += "0";
            NumberFormat nf = new DecimalFormat("0."+places);
            return Double.parseDouble(nf.format(d));
        }
}
}
并传递变量

${col} 
作为双参数-d,然后任何数字都可以用于deplaces。 任何帮助都将不胜感激,谢谢

 ${func:roundOff(col, 1)}
应该这样做。但是,好的,taglib文件中的签名应该是

double roundOff(double, int)
                      ^--- comma here.
如果这不起作用,那么请提及您收到的确切错误消息,而不是仅仅说“它不起作用”

应该这样做。但是,好的,taglib文件中的签名应该是

double roundOff(double, int)
                      ^--- comma here.

如果这不起作用,那么请提及您收到的确切错误消息,而不是仅仅说“它不起作用”。

谢谢,伙计。我只是没看到那个逗号。你救了我一天!谢谢你,伙计。我只是没看到那个逗号。你救了我一天!
 ${func:roundOff(col, 1)}
double roundOff(double, int)
                      ^--- comma here.