The request sent by the client was syntactically incorrect ()问题
2015-12-07 15:29
387 查看
这两天试着做web项目碰到不少问题,其中一个就是使用springmvc时提交一个请求,返回400如题所示的问题,网上搜了一下,多数回答都是以下两种:
1.请求表单中参数和controller中的接收参数不匹配。
2.必选参数没传。
3.int型参数传了null。
我的controller中接收方法如下:
调试请求参数,最后发现原来是NoteEntity中的某个id为long型,而前台页面提交请求时并没有给这个同名input赋值,这就导致了把null赋给基本数据类型的错误。最后的解决方案是改为Long封装类型。
1.请求表单中参数和controller中的接收参数不匹配。
2.必选参数没传。
3.int型参数传了null。
我的controller中接收方法如下:
@RequestMapping(value = "saveNote", method = RequestMethod.POST) @RequiresPermissions(value = { "note_create", "note_edit" }, logical = Logical.OR) public String save(NoteEntity noteEntity, HttpSession session) throws Exception { if (noteEntity == null || noteEntity.getId() == null) { noteEntity.setCreated(System.currentTimeMillis()); } noteService.save(noteEntity); session.setAttribute("message", SAVE_SUCCESS); return "redirect:/admin/note/listNote"; }
调试请求参数,最后发现原来是NoteEntity中的某个id为long型,而前台页面提交请求时并没有给这个同名input赋值,这就导致了把null赋给基本数据类型的错误。最后的解决方案是改为Long封装类型。
相关文章推荐
- UID_PS_01_大师之路
- APUE学习之----进程通信pipe实现管道
- 队列ArrayBlockingQueue的使用
- 偶然翻出很久很久以前写的一款sqlmap UI,有点年头了
- 基于jQuey实现鼠标滑过变色(整行变色)
- django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法
- UI控件-UITextField
- [DP] Unique Binary Search Trees
- UICollectionView关于item的报错
- 270. Closest Binary Search Tree Value
- UIView的hitTest:方法和pointInside:方法的实现
- 顺序容器Vector,List,,Deque区别
- UIImageView-播放序列图(简单的动画效果实现)
- 容器(三):队列容器Deque
- configure.in:18: required file `build/ltmain.sh' not found
- jsp Request获取url信息的各种方法比较
- heat template: get_param to get value from JSON param.
- easyui 获得父级tabs跳转
- 使用 CreateTimerQueueTimer 定时器时需要注意的一个参数
- iOS--- UITableView + UISearchDisplayController - - - - -实现搜索功能