日期:2014-05-19 浏览次数:20754 次
@Entity
@Table(name="tbl_users")
public class User {
private int id;
private String userName;
private String password;
private Date birthday;
private Date inDate;
private int age;
private Department department;
private Date testDate;
@Id
@Column(name="user_id")
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
}
//还有其他的get、set方法
@RequestMapping(value="/addOrUpdate")
@ResponseBody
public Map<String, String> addOrUpdate(User user){
Map<String, String> result = new HashMap<String, String>();
//User user = null;
//request.getParameter("newUser");
try{
userService.save(user);
result.put("message", "操作成功!");
} catch (Exception ex){
ex.printStackTrace();
logger.error(ex.getMessage());
result.put("message", "操作失败!");
}
return result;
}
function addOrUpdateUser(){
var r = $('#userForm').form('validate');
if(!r) {
return false;
}
var id = $("input[name='id']").val();
var name = $("input[name='name']").val();
var password = $("input[name='password']").val();
var age = $("input[name='age']").val();
var birthday = $("input[name='birthday']").val();
var