Hi everyone !
I'm new to DWR. I'm working on a project using DWR. I met a problem,when I call the server-side code.
anonymous("\r\n//#DWR-INSERT\r\n//#DWR-REPLY\r\ndwr.engine.remote.handleException("1","0",{javaClassName:"java.lang.Throwable",message:"Error"}); \r\n")engine.js (第 545 行)
anonymous()Server-side code:
public class PasswordService {
public void changePassword(String oldPassword, String newPassword) throws WrongPasswordException{
HttpSession session = (WebContextFactory.get()).getSession();
// Get user's name
String name = ((User)session.getAttribute("user")).getName();
if (name !=null && oldPassword != null && newPassword != null) {
if (!changePassword(name, oldPassword, newPassword)) {
throw new WrongPasswordException();
}
}
}
}
Client-side Javascript code:
function change() {
var name = dwr.util.getValue("name");
var oldpsw = dwr.util.getValue("oldpassword");
var newpsw = dwr.util.getValue("newpassword");
Psw.changePassword(name,oldpsw,newpsw);
}
错误原因:
Javascript调用PasswordService类的函数Psw.changePassword()的参数与原java函数的方法不匹配。
可怜我整一个下午,都是粗心的惹得祸,修改代码是漏改的结果。
没有评论:
发表评论