标签:res sys jquery .post out ppi springmvc cti text
1.首先,使用jquery实现ajak,需导入jquery.js
2.ajax.jsp页面代码
<script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $("#name").blur(function(){ $.post("ajax.do",{‘name‘:$("#name").val()},function(data){ $("#lable").html(data); }); }); }); </script> </head> <body> 离开后提交,并改变lable的值<br> input:<input id="name" type="text" name="name"><br> lable:<label id="lable">null</label><br> </body>
3.Controller.java
@Controller public class AjaxController { @RequestMapping("/ajax") public void ajax(HttpServletRequest req, HttpServletResponse resp) throws IOException { //参数接收使用getParameter或在方法中定义形式参数 String name=req.getParameter("name"); resp.getWriter().print(name); // System.out.println(name); } }
标签:res sys jquery .post out ppi springmvc cti text
原文地址:http://www.cnblogs.com/xiaohongxin/p/6523277.html