如何将数据从 bootstrap x-editable 发送到 servlet?目前我的设置是这样的:
$(document).ready( function() {
$('a.accordion-toggle').editable({
ajaxOptions: {
dataType: 'json'
},
placement: 'right',
name: 'toEdit',
url: '../admin/module_edit.do',
title: 'Edit'
});
});
我的servlet是这样的:
@RequestMapping( value = "/admin/module_edit", method = RequestMethod.POST )
public @ResponseBody
String editSubjectAndStrand( @RequestParam
String toEdit, HttpServletRequest request )
{
System.out.println( toEdit );
return "";
}
它现在没有在我的服务器端打印任何内容。我做错了什么?
最佳答案
终于发现错误了。我还应该定义 pk 来将 ajax 请求发送到服务器。 documentation帮我解决这个问题。文档中有这部分:
Main attributes you should define are:
type - type of input (text, textarea, select, etc)
url - url to server-side script to process submitted value (/post, post.php etc)
pk - primary key of record to be updated (ID in db)
id or name - name of field to be updated (column in db). Taken from id or data-name attribute
value - initial value. Usefull for select, where value is integer key of text to be shown. If empty - will be taken from element html contents
关于java - 从 bootstrap x-editable 发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19925984/