springMVC在jsp传对象到后台
==============实体entity=======================
package com.jb.pub.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import com.jb.tool.Savebackground;
/**
* 用户
*/
@Entity
public class Pubuser implements Serializable {
private static final long serialVersionUID = 8235691405047796440L;
private String aguid;
public String getAguid() {
return aguid;
}
public void setAguid(String aguid) {
this.aguid = aguid;
}
}
=============action===================
package com.jb.pub.controller;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jb.pub.entity.Pubbm;
import com.jb.pub.entity.Pubjob;
import com.jb.pub.entity.Pubuser;
import com.jb.pub.services.PubuserServices;
import com.jb.tool.JTool;
import com.jb.tool.JToolType;
@Controller
@RequestMapping("index")
public class PubuserAction {
@Autowired
public PubuserServices pub;
@RequestMapping("mgAdd")
public String saveUser(Pubuser pubuser,HttpServletRequest request){//Pubuser pubuser一定要设置为参数
try {
pub.savUser(pubuser);//添加的方法
} catch (Exception e) {
e.printStackTrace();
}finally{
return "PubUser_gl";
}
}
===============jsp===========================
<form action="index/mgAdd.do" method="post" id="frmadd">
<input type="text" name="aguid"/><!--注意这里必须和实体名称一致-->
</form>