jquery ajax 的data 存表单的值

时间:2021-02-01 23:25:52

jsp

<body>
 <form action="" method="post" id="formid">
  <input type="text" name="guid_gs"> <input type="text"
   name="acode"> <input type="text" name="zjm">

</form>
 <a href="javascript:gettitle();">进入</a>
</body>

JS

$.ajax({
  type : "POST",
  url : "Testasd.hml",
  data : $('#formid').serialize(),//表单ID
  success : function(msg) {

}
 });

后台代码

public String loadinit(Pubuser pubuser, HttpServletRequest request,
   HttpServletResponse response) throws IOException {

System.out.println(pubuser.getGuid_gs());
  System.out.println(pubuser.getAcode());
  System.out.println(pubuser.getZjm());
  return null;
 }