spring dwr engine.js失败未知错误

zazmityj  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(323)

我们有一个使用springframework5.1.7.release、jdk1.8和dwr3.0.2的web应用程序,部署在was8.5中。我们有一个jsp网页;它向用户显示一些统计信息;网页运行得很好,就像几年前一样,突然它开始无法加载。当我们调试问题时;我们把范围缩小到dwr的ajax请求;它在engine.js中失败,出现未知错误。我们所想的;我们将提供信息来回答这个问题。下面是代码段,它在下面的第3行继续失败,即controllerclass.somemethod调用。selectobj1和selectobj2是数组类型的对象。

if (document.getElementById("someCheckBox").checked) {
    //Below controllerClass is the name of JS class produced by DWR but actually it's a Java class (i.e. object used below)
    controllerClass.someMethod("Value1", selectObj1, selectObj2, 'Value2', 'Value1', function(data) {
    if (data != null) {
         hideView("viewOne",false);     //user defined function call
         fillData("viewName",data[0]);  //user defined function to fill the returned data
         valueRet1 = data[1]; 
         someConst = "X";
         displayNavCon(pageNumber);  //user defined function to control the navigation on web page
      }  else {
        alert("No Data Found!!!");  
        recordCount=0;
    }
});
7qhs6swi

7qhs6swi1#

当涉及到dwr时,它启动失败,并在engine.js中出错;我认为dwr需要做一些改进。因为大部分时间错误是未知的。所以在上面的例子中——我们在dwr的ajax调用中使用selectobj1(像数组一样)和selectobj2(像数组一样)传递一些数据,数据的构造方式多年来没有改变;然后我们注意到在selectobj1中传递了一个带有逗号的十进制值,在将数据提供给dwr的ajax调用和bingo之前,我们去掉了逗号!成功了。代码修复如下;

//we are omitting the construction of other object being passed in i.e. selectObj2
var indexBrkLp = 0;
if (priceVal != null){
    while (priceVal.includes(",")){
        indexBrkLp++;
        priceVal = priceVal.replace(",", "")
        if (indexBrkLp > 5){
            break;
        }
    }
}

var selectObj1={
    val2:(val2 == null? "": val2),
    priceVal :(priceVal == null? "": priceVal)
};

if (document.getElementById("someCheckBox").checked) {
    //Below controllerClass is the name of JS class produced by DWR but actually it's a Java class (i.e. object used below)
    controllerClass.someMethod("Value1", selectObj1, selectObj2, 'Value2', 'Value1', function(data) {
    if (data != null) {
         hideView("viewOne",false);     //user defined function call
         fillData("viewName",data[0]);  //user defined function to fill the returned data
         valueRet1 = data[1]; 
         someConst = "X";
         displayNavCon(pageNumber); //user defined function to control the navigation on web page
      }  else {
        alert("No Data Found!!!");  
        recordCount=0;
    }
});

结论-如果您看到engine.js失败了,那么它可能不仅仅是代码中的错误;它可能是它不喜欢的数据,也可能是与dwr相关的其他配置。

相关问题