The request sent by the client was syntactically incorrect ()问题

这两天试着做web项目碰到不少问题,其中一个就是使用springmvc时提交一个请求,返回400如题所示的问题,网上搜了一下,多数回答都是以下两种:

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封装类型。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值