大家好我使用DWR来处理Java的servlet的Ajax调用,
这就是我的dwr.xml,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="TempCardServlet">
<param name="class" value="com.slingmeadia.notifier.servlet.TempCardServlet"/>
</create>
</allow>
</dwr>
这是什么我的servlet文件和我打电话
package com.slingmeadia.notifier.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class TempCardServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String funtionType="";
if(request.getParameter("functiontype")!=null){
funtionType = (String)request.getParameter("functiontype");
}
if(funtionType.equals("logout")){
processLogout(request, response);
}else{
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processLogout(request, response);
}
public Map sampleFill(int empid,String functiontype){
System.out.println("functiontype : "+functiontype);
Map employeeData = new LinkedHashMap();
if(functiontype.equals("add")){
employeeData.put("name", "Antony");
}else{
employeeData.put("name", "Antony");
employeeData.put("cardnumber", "87896857852");
employeeData.put("issuedate", "17/01/2012");
}
return employeeData;
}
}
这就是我如何从调用JSP文件的方法:
<script src='dwr/engine.js'></script>
<script src='dwr/util.js'></script>
<script src='dwr/interface/TempCardServlet.js'></script>
<script>
function getValues(id) {
var empid = id.value;
var optionValue = document.getElementById("selectedOption").value;
TempCardServlet.sampleFill(empid,optionValue,{callback:setValues,async:false});
}
function setValues(tempcardMap) {
if(tempcardMap !=null){
document.getElementById("empname").value=tempcardMap.name;
document.getElementById("tempcardnumber").value=tempcardMap.cardnumber;
document.getElementById("dateofissue").value=tempcardMap.issuedate;
}
}
</script>
这该怎么做我的JavaScript方法的调用:
<td width="55%"><input class="inputBoxes" type="text" name="empid" id="empid" onblur="getValues(this)" /></td>
似乎一切都安排好,没有问题,但它不工作,不给任何excetpion也。
我想这样也
在URL我输入http://localhost:8080/acct/dwr/index.html
它让我知道DWR类的列表:和我的类文件也有,当我试图打开浏览器从类文件,并给出了一些样品的输入,但不给任何错误也没有输出。
请帮我解决这个问题。
问候。