Spring句柄jQuery可排序
我使用的是jQuery排序表,就像中的一样。我要序列化并发送到服务器的代码如下:Spring句柄jQuery可排序,spring,spring-mvc,jquery-ui-sortable,Spring,Spring Mvc,Jquery Ui Sortable,我使用的是jQuery排序表,就像中的一样。我要序列化并发送到服务器的代码如下: $(function() { $( "#sortable" ).sortable({ update: function (event, ui) { var data = $(this).sortable('serialize'); $.ajax({ //data: data, ty
$(function() {
$( "#sortable" ).sortable({
update: function (event, ui) {
var data = $(this).sortable('serialize');
$.ajax({
//data: data,
type: 'GET',
url: '/categoryId/order?order=' + data
});
}
});
$( "#sortable" ).disableSelection();
});
在Spring端,我的方法签名是:
@RequestMapping(value = "/{categoryId}", method = RequestMethod.GET)
public ModelAndView saveOrder(HttpServletRequest request, @RequestParam("order") List<String> order, @PathVariable("categoryId") String categoryId) throws Exception {
@RequestMapping(value=“/{categoryId}”,method=RequestMethod.GET)
公共模型和视图存储顺序(HttpServletRequest请求、@RequestParam(“order”)列表顺序、@PathVariable(“categoryId”)字符串categoryId)引发异常{
但是,我无法让spring处理发送到列表中的订单。我在浏览器上看到一个400(错误请求)错误:
必需的列表参数“订单”不存在
来自浏览器的调用是:
/类别ID?订单[]=1和订单[]=0和订单[]=2和订单[]=3和订单[]=4和订单[]=5将
@RequestParam(“订单”)
替换为@RequestParam(“订单[]”)
或
将
/categoryId?order[]=1&order[]=0&order[]=2&order[]=3&order[]=4&order[]=5
替换为/categoryId?order=1&order=0&order=2&order=3&order=4&order=5
var data=sortable('serialize'))返回字符串,因此使用@RequestParam(“数据”)字符串s;您确定,您的请求有参数订单
?我猜您进入页面时没有参数初始值,并且由于@RequestParam
的require属性的默认值为true,因此引发了错误。我没有试图解决缺少订单参数的问题。我确实想处理它。