<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 概述 只要頁面提交的數據都是字符串類型的.但是封裝的時候都變成了我們想要的數據類型.但是有些數據不能封裝為我們想要的類型. ## 需要實現的接口 所有類型轉換都要實現這個接口 ~~~ package org.springframework.core.convert.converter; import org.springframework.lang.Nullable; @FunctionalInterface public interface Converter<S, T> { //S是源類型,T是目標類型 @Nullable T convert(S var1); } ~~~ ## 自定義轉換器 ~~~ package com.like.utils; import org.springframework.core.convert.converter.Converter; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class StringtoDateConverter implements Converter<String, Date> { @Override public Date convert(String s) { if (s == null) { throw new RuntimeException("請您傳入數據"); } try { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.parse(s); } catch (ParseException e) { throw new RuntimeException("數據轉換出現錯誤"); } } } ~~~ ## 配置 ~~~ <!--自定義類型轉換器--> <bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"> <property name="converters"> <set> <bean class="com.like.utils.StringToDateConverter"/> </set> </property> </bean> <!--開啟springMVC注解支持--> <mvc:annotation-driven conversion-service="conversionService"/> ~~~ ![](https://box.kancloud.cn/03c6fff07ad6a80e0f392a1899767a86_1822x244.png) 結果: ``` User{username='jack', age=20, date=Tue Mar 10 00:00:00 CST 1992} ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看