*更新
我是 grails 和 stack 的新手。我正在尝试在控制器中实例化一个 java 类。我的 .java 文件位于 /src 文件夹中。我已经在 grails 之外测试了这个类,它工作正常。但是,当我尝试从控制器实例化它时,我得到一个空指针异常。我的相关代码:
package matrices
import org.springframework.dao.DataIntegrityViolationException
class MFController {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
def index() {
MatrixFactorization m = new MatrixFactorization()
def answer = m.getAnswer().toString()
return answer
}
我的踪迹:
Message: null
Line | Method
->> 45 | run in matrices.MatrixFactorization
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 36 | <init> in ''
| 10 | index . . in matrices.MFController$$ENtqy0Aa
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
矩阵分解类 35-45
public MatrixFactorization() {
double[] l1 = { 5, 3, 0, 1 };
double[] l2 = { 4, 0, 0, 1 };
double[] l3 = { 1, 1, 0, 5 };
double[] l4 = { 1, 0, 0, 4 };
double[] l5 = { 0, 1, 5, 4 }; //45
提前致谢