zoukankan      html  css  js  c++  java
  • SpringMVC中的400错误,The request sent by the client was syntactically incorrect.

    在其他对象属性类型一样情况下,只需要创建一个类,再在springmvc.xml中添加配置:

    package com.ujiuye.common;
    
    import org.springframework.core.convert.converter.Converter;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    public class DateTimeConverter implements Converter<String, Date> {
        public Date convert(String s) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            try{
                Date date = sdf.parse(s);
                return date;
            }catch (Exception ex){
                System.out.println(ex.getMessage());
                return null;
            }
        }
    }
    <!--全局类型转型器-->
        <bean id="converter" class="com.ujiuye.common.DateTimeConverter"></bean>
        <bean id="formattingConversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
            <property name="converters">
                <set>
                    <ref bean="converter"></ref>
                </set>
            </property>
        </bean>
        <mvc:annotation-driven conversion-service="formattingConversionService"/>
    
    <mvc:annotation-driven/>
  • 相关阅读:
    A
    博弈论
    K
    快速幂
    基数排序
    计数排序
    KMP求字符串最小循环节
    二分图多重匹配
    hdu2818行列匹配+排序
    二分图行列匹配与最大匹配必须边
  • 原文地址:https://www.cnblogs.com/chen4j/p/11945393.html
Copyright © 2011-2022 走看看