我正在使用 Servlet 使用 mysql 数据库数据填充 jsp 页表,并使用 jquery 数据表插件使表可编辑。
但是,表格编辑不起作用,每次我编辑字段并按“Enter”时都会收到错误“无法更新单元格(服务器错误)”。我的 doPost 方法是否还在运行?
这是我的 jquery 脚本:
<script type="text/javascript">
$(document).ready(function(){
oTable = $("table#datatables").dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[2, "desc"]],
"bJQueryUI":true,
"sDom": '<"top"i><"title">lt<"bottom"pf>'
}).makeEditable({
"sUpdateURL": "/home",
"aoColumns": [
null, //medical record number
{}, //last name; default editing
{}, //first name; default editing
{}, //middle name; default editing
{}, //date of birth; default editing
{ //gender, selection between M and F
indicator: 'Saving...',
tooltip: 'Click to select gender',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
data: "{'M':'M','F':'F'}"
},
null, //admission date time
null, //discharge date time
null, //attending physician
{} //room; default editing
]
});
});
</script>
这是我家 Servlet 的 doPost 方法
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int id = Integer.parseInt(request.getParameter("id"));
int columnId = Integer.parseInt(request.getParameter("columnId"));
int columnPosition = Integer.parseInt(request.getParameter("columnPosition"));
int rowId = Integer.parseInt(request.getParameter("rowId"));
String value = request.getParameter("value");
String columnName = request.getParameter("columnName");
System.out.println(value);
}
我的 servlet 的 URL 映射是“/home”