【发布时间】:2016-07-23 23:37:51
【问题描述】:
我正在使用 hibernate spring MVC 和 JS 制作 CRUD 应用程序.. 现在我正在删除数据库中的一行.. 这是我的代码 我的js
deleteRow : function() {
$("input:checkbox:checked").each(bindContext(function(index, item) {
var str = $(item).attr("id");
str = str.substring(str.indexOf("_") + 1);
$.ajax({
url : '/Spring3HibernateApp1/delete',
type : 'POST',
data : {
"id" : str,
}
});
this.data.splice(str, 1);
this.deleteTable();
this.display();
}, this));
},
我的控制器
@RequestMapping(value = "/delete")
public @ResponseBody void doPostDelete(@RequestBody String id,Employee employee){
int idInt = Integer.parseInt(id);
employee.setEmpId(idInt-1);
employeeService.deleteEmployee(employee);
}
它进入控制器并显示 jquery.min.js:4 POST http://localhost:8080/Spring3HibernateApp1/delete 500 (Internal Server Error)
有什么建议吗??
【问题讨论】:
-
你能提供堆栈跟踪吗?
-
没有看到任何日志,我认为您正在托盘转换来自
String id的非字符串数字表示形式的数字...您可以打印id值吗? -
点击删除按钮时..我试图捕捉员工的 id 并将其发送到控制器并从数据库中删除它
-
@Hector 有什么想法吗?
-
您能否验证您正在发送
id变量中的数字?或提供堆栈跟踪?
标签: javascript java spring hibernate spring-mvc