The request sent by the client was syntactically incorrect ()

    xiaoxiao2021-03-25  56

    在练手的一个ssm项目中,首次遇到这个错误。上网查了资料发现这是SpringMvc的问题。都说原因是jsp页面中标签的参数和controller中方法的参数不匹配造成的。但是我反复对了几遍实体类和jsp页面中标签的name属性,都是对应的,并没有错误. 然后又换了一种方法 加入了log4j日志工具,将日志级别改成了最低的debug级别,但是测试log4j都没有报出错误信息,所以还是没找出原因。最后在测试时发现应该是在日期转换中出了问题。jsp页面中 日期的数据传不到controller的方法中.于是在网上找到了这段代码,将其将入controller中,

    @initBinder public void initBinder(WebDataBinder binder, WebRequest request) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true)); binder.registerCustomEditor(Timestamp.class, new CustomDateEditor(df, true)); }

    但是还是有问题。在增加数据时,一定要将所有关于的时间数据都填好,否则还是会报上面一样的错误。 问题还在解决中,先暂时记录一下,等找到解决的方法,再更新文章.

    转载请注明原文地址: https://ju.6miu.com/read-36556.html

    最新回复(0)