Activiti modoler 整合后报错 TypeError: Cannot read property ‘namespace‘ of undefined

之前在Demo整合过没问题,结果好不容易整合到现在的项目,结果出现成这个鬼样子……问题找了好久,一直以为是SpringSecurity请求限制没放开,所以找SpringSecurity的debug日志,浏览器请求有没有404、500、502等,结果一切正常,最后才想起来看浏览器控制台,然后百度一圈没有解决方案,只能自己慢慢找了。
Activiti modoler加载失败页面

问题剖析

每个人的问题可能都不一样,这里提供问题解决思路,一劳永逸解决问题。

TypeError: Cannot read properties of undefined (reading 'namespace')
    at classDef.construct (oryx.debug.js:10913:34)
    at new classDef (oryx.debug.js:1747:54)
    at app.js:107:45
    at angular.min.js:67:279
    at B (angular.min.js:94:5)
    at B (angular.min.js:94:5)
    at angular.min.js:95:173
    at h.$eval (angular.min.js:103:456)
    at h.$digest (angular.min.js:101:218)

找到最核心的app.js:107:45,代码如下

function fetchModel(modelId) {
    var modelUrl = KISBPM.URL.getModel(modelId);

    $http({method: 'GET', url: modelUrl}).
    success(function (data, status, headers, config) {
        $rootScope.editor = new ORYX.Editor(data); //这里报错
        $rootScope.modelData = angular.fromJson(data);
        $rootScope.editorFactory.resolve();
    }).
    error(function (data, status, headers, config) {
        console.log('Error loading model with id ' + modelId + ' ' + data);
    });
}

使用console.log打印data的值瞬间明白了,我的项目使用ResponseBodyAdvice拦截了所有请求,将JSON格式的返回值都规范化,因此解析失败

解决方案1:限制ResponseBodyAdvice作用范围

@RestControllerAdvice(basePackages = "com.xk857.module") //将其限制在项目业务层部分
public class ResponseHandler implements ResponseBodyAdvice<Object> {
	// ……
}

解决方案2:修改js

这个需要按自己项目来,我的项目返回值都在data中,所以要写成 data.data 才可以

function fetchModel(modelId) {
    var modelUrl = KISBPM.URL.getModel(modelId);

    $http({method: 'GET', url: modelUrl}).
    success(function (data, status, headers, config) {
        $rootScope.editor = new ORYX.Editor(data.data);
        $rootScope.modelData = angular.fromJson(data.data);
        $rootScope.editorFactory.resolve();
    }).
    error(function (data, status, headers, config) {
        console.log('Error loading model with id ' + modelId + ' ' + data);
    });
}

运行成功界面

BUG查找不易,点个赞再走吧~~~

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CV大魔王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值