dwr未定义解决

<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/LoginDwr.js'></script> 
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type="text/javascript">
function doLogin(){
    var userName = document.getElementById("username");
    LoginDwr.login(userName,handleLogin);
}
function handleLogin(date){
    alert(date);
}
</script>

LoginDwr

public String login(String userName){
    return "Hello"+userName;
}

dwr.xml

<create creator="new" javascript="LoginDwr">
<param name="class" value="helloworld.LoginDwr"/>
</create>

仔细检查了几遍,没发现什么错误,问了挺多人,也没解决。后来到网上搜,有人说下个xalan-j_2_7_0-bin.zip
解压把里面的jar拷到tomcat\common\endorsed目录下,果然奏效。具体这个东西有什么用,我也不清楚。

你可能感兴趣的:(JavaScript,tomcat,xml,DWR,J#)