function sayHello() {
var userName=dojo.byId("userName").value;
dojo.xhrGet({
url: "<%=request.getContextPath()%>/test.do?method=test",
handleAs: "text",
content: { key1:userName,key2: "value2",key3: "value3" },
load: function(responseText)
{
dojo.byId("first_name").value = responseText;
dojo.byId("t1").value = responseText;
dijit.byId("description").value = responseText;
document.getElementById("middle_initial").value=responseText;
},
error: function(response)
{
alert("Error");
}
});
}
2.后台action中:
public ActionForward test(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"); out.print(key1); return null; }