jquery ajax 序列化表单传参提交实体对象到后台action
========action后臺我這里使用的是SpringMVC如果用ssh用法一致===============
@Controller
@RequestMapping("PubjobController")
public class PubjobController {
?@Autowired
?public PubjobServices pubjobServices;//業(yè)務(wù)層使用注解的方式
?//Pubjob? 實體
?@RequestMapping("jobMgs")
?public String jobMgs(Pubjob job,HttpServletRequest request, HttpServletResponse response)
???throws IOException {
System.out.print(job.getId());
System.out.print(job.getName());???
response.getWriter().write("操作成功!");
?? ?response.getWriter().close();
??return null;
?}
?
?
===========js==============
$.ajax({
????type : "POST",
????url : '/jubcrm/PubjobController/jobMgs.hml',
????data :? $("#frmjob").serialize(),//序列化表單提交input 值
????success : function(msg) {
alert(msg);???????
?}
?????},
????error : function(msg) {
?????$.messager.alert(prompts(), "操作失敗");
????}
???});
?
==========jsp(input 的name必須和實體名稱一致)==================
<form method="post" id="frmjob" name="frmjob" action="">
????名稱:<input type="text" name="name"? />??????
????id:<input name="id" type="text" />
????</form>
轉(zhuǎn)載于:https://www.cnblogs.com/qgc88/p/3363133.html
總結(jié)
以上是生活随笔為你收集整理的jquery ajax 序列化表单传参提交实体对象到后台action的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Arduino 各种模块篇 motor
- 下一篇: 实验 3 简单的分支与循环结构