一步一步坑上爬之动态sql坑
Error updating database. Cause: java.sql.SQLException: Field ‘goods_name’ doesn’t have a default value
The error may involve com.xuwem.show.mapper.OrderMapper.add-Inline
The error occurred while setting parameters
SQL: insert into ord ( user_id, charge_id, price, goods_num ) values( ?, ?, ?, ? )
Cause: java.sql.SQLException: Field ‘goods_name’ doesn’t have a default value
]
DEBUG [http-bio-9000-exec-1] - Written [com.xuwem.show.pojo.Result@377c7911] as “application/json;charset=UTF-8” using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@2f0d55dc]
DEBUG [http-bio-9000-exec-1] - Null ModelAndView returned to DispatcherServlet with name ‘springmvc’: assuming HandlerAdapter completed request handling
DEBUG [http-bio-9000-exec-1] - Successfully completed request
这里提示我动态sql出现问题,但是查看日志,语法没有什么问题。于是去前段查看参数绑定
参数是绑好的,也没有问题。
我就打印了移一下前端的传值,是空的。
问题来了,前台往后台的传值为空,才导致问题出现。那么,为什么会是空呢。
…
仔细检查后才知道,我前端绑参数是包装pojo,但是我springmvc里接收参数是包装pojo里的pojo,这才导致问题出现。

修改参数类型,提取我要的参数,问题解决,特以此记录。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
