springMVC 页面填写日期运行时发生异常!The request sent by the client was syntactically incorrect
2017-09-04 10:12
381 查看
运行工程就发生异常:
The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的!
Spring在转换日期出错了!
解决:
(1)
(2)springmvc配置
The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的!
Spring在转换日期出错了!
解决:
(1)
需要实现Converter接口,这里是将String类型转换成Date类型
/** * 将字符串转换成日期 * * 需要实现Converter接口,这里是将String类型转换成Date类型 * @author Administrator * */ public class StringToDateConverter implements Converter<String, Date> { @Override public Date convert(String arg0) { // 日期格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return sdf.parse(arg0); //解析 } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }
(2)springmvc配置
<!--5. 自定义参数 --> <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <!-- 转换器 --> <property name="converters"> <list> <bean class="com.hlx.util.StringToDateConverter" /> <!-- 自定义的日期 --> </list> </property> </bean> <!-- 指定自定义参数 --> <mvc:annotation-driven conversion-service="conversionService" />
相关文章推荐
- springMVC日期转换及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.解决办法
- SpringMVC 出现"The request sent by the client was syntactically incorrect ()"解决办法
- SpringMVC---400错误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.
- SpringMVC 表单提交参数不匹配报错 提交表单报400错:description 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-SpringMVC问题详解
- SpringMVC-使用converter转换器解决后台接收Date格式数据时The request sent by the client was syntactically incorrect ()
- springmvc报错:The request sent by the client was syntactically incorrect
- springMVC报出400,The request sent by the client was syntactically incorrect.
- SpringMVC---400错误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 ()的解决
- POST 400 Bad Request The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect ()
- HTTP Status 400 - description The request sent by the client was syntactically incorrect.