springMVC日期转换及The request sent by the client was syntactically incorrect.解决办法
2017-01-18 16:37
776 查看
今天在前端通过日期插件查询时出现错误:
springMVC参数错误。细查之后原来是因为前端传过去的是String类型,而接受数据的类型为Date类型,这时有2中解决办法:
springMVC参数错误。细查之后原来是因为前端传过去的是String类型,而接受数据的类型为Date类型,这时有2中解决办法:
一、日期格式转换:
通过SimpleDateFormat.parse(“”)把参数格式化为Date类型。二、通过springMVC.xml配置日期转换。
在springMVC的xml配置文件中添加如下代码:<mvc:annotation-driven conversion-service="conversionService" /> <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="registerDefaultFormatters" value="true" /> <property name="formatterRegistrars"> <set> <bean class="org.springframework.format.datetime.DateFormatterRegistrar"> <property name="formatter" ref="dateFormatter"></property> </bean> </set> </property> </bean> <bean id="dateFormatter" class="org.springframework.format.datetime.DateFormatter"> <property name="pattern" value="yyyy-MM-dd"></property> </bean>
相关文章推荐
- springMVC日期转换及The request sent by the client was syntactically incorrect.解决办法
- SpringMVC 出现"The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法 .
- Spring MVC "The request sent by the client was syntactically incorrect "解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- The request sent by the client was syntactically incorrect (). 的某个解决办法
- 用 @ModelAttribute 出现The request sent by the client was syntactically incorrect.的解决办法
- 解决SpringMVC入参出现The request sent by the client was syntactically incorrect请求语法错误方法
- The request sent by the client was syntactically incorrect解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC "The request sent by the client was syntactically incorrect "解决办法
- Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法
- SpringMVC-使用converter转换器解决后台接收Date格式数据时The request sent by the client was syntactically incorrect ()
- The request sent by the client was syntactically incorrect ()"解决办法
- springMVC 页面填写日期运行时发生异常!The request sent by the client was syntactically incorrect
- Springmvc注解开发:日期类型参数封装报错:The request sent by the client was syntactically incorrect.