[英]Spring DWR engine.js failing unknown error
We have a web application that is using Spring framework 5.1.7.RELEASE , JDK 1.8 and DWR 3.0.2 deployed in WAS 8.5 .我们有一个 web 应用程序,它使用Spring 框架 5.1.7.RELEASE 、 JDK 1.8和DWR 3.0.2部署在WAS 8.5中。 We have a JSP web page;
我们有一个 JSP web 页面; that displays some statistical information to its user;
向其用户显示一些统计信息; web page was working fine like in years and all of a sudden it started failing to load.
web 页面多年来一直运行良好,但突然间开始无法加载。 When we debugged the issue;
当我们调试问题时; we narrow it down to dwr's ajax request;
我们将其缩小到 dwr 的 ajax 请求; and it failed in engine.js with an unknown error.
它在engine.js中失败,出现未知错误。 What we figured;
我们的想法; we will provide the information in answer to this question.
我们将提供信息来回答这个问题。 Code snippet is below, and it continue to fail on line '3' below ie controllerClass.someMethod call.
代码片段如下,它在下面的第 3 行继续失败,即controllerClass.someMethod调用。 selectObj1 and selectObj2 are array type of objects.
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;
}
});
When it comes to DWR and it start's failing with an error in engine.js ;当涉及到 DWR 时,它开始失败,并在engine.js中出现错误; I think DWR needs to put some improvements there.
我认为DWR需要在那里进行一些改进。 Because most of the time error is/was unknown.
因为大多数时候错误是/未知的。 So in above case - we were passing some data in DWR's ajax call using selectObj1 like an array and selectObj2 like an array, how data being constructed haven't changed in years;
所以在上面的例子中——我们在 DWR 的 ajax 调用中传递了一些数据,使用selectObj1像一个数组和selectObj2像一个数组,构造数据的方式多年来没有改变; then we noticed that there was a decimal value being passed in selectObj1 that has comma in it, we removed the comma before giving data to DWR's ajax call and Bingo.
然后我们注意到在selectObj1中传递了一个包含逗号的十进制值,我们在将数据提供给 DWR 的 ajax 调用和 Bingo 之前删除了逗号。 it worked;
有效; Code fix is below;
代码修复如下;
//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;
}
});
Conclusion - If you see engine.js is failing, then it might not just be something wrong in your code;结论 - 如果你看到engine.js失败了,那么它可能不仅仅是你的代码有问题; it could be data that it don't like or could be some other config related to DWR .
它可能是它不喜欢的数据,也可能是与DWR相关的其他配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.