dojo中客户端向服务器提交数据

前端之家收集整理的这篇文章主要介绍了dojo中客户端向服务器提交数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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; }
原文链接:https://www.f2er.com/dojo/291729.html

猜你在找的Dojo相关文章