1.js脚本:

<script> 
function handler(data) 
{ 
     alert("data="+data);
  } 
function submitForm(){ 
     dojo.xhrGet({
          url: "<%=request.getContextPath()%>/test.do?method=test2", 
        form: "main1", 
        handleAs: "text", 
        handle: handler, 
        content: {pwd:"modified"}, 
        sync:true 
     }); 
} 
</script> 

2.HTML代码:

<form id="main1">
<input type="text" name="key1"/>
<input type="button" value="touch"/>
</form>

3.Java代码:

    public ActionForward test2(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        String key1=request.getParameter("key1");
        String pwd=request.getParameter("pwd");
        System.out.println("pwd="+pwd);
        out.print(key1);
        return null;
    }