久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='KA0vb'></tfoot>
  • <legend id='KA0vb'><style id='KA0vb'><dir id='KA0vb'><q id='KA0vb'></q></dir></style></legend>

    <small id='KA0vb'></small><noframes id='KA0vb'>

      <bdo id='KA0vb'></bdo><ul id='KA0vb'></ul>

        <i id='KA0vb'><tr id='KA0vb'><dt id='KA0vb'><q id='KA0vb'><span id='KA0vb'><b id='KA0vb'><form id='KA0vb'><ins id='KA0vb'></ins><ul id='KA0vb'></ul><sub id='KA0vb'></sub></form><legend id='KA0vb'></legend><bdo id='KA0vb'><pre id='KA0vb'><center id='KA0vb'></center></pre></bdo></b><th id='KA0vb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KA0vb'><tfoot id='KA0vb'></tfoot><dl id='KA0vb'><fieldset id='KA0vb'></fieldset></dl></div>

        使用 JSR303 驗(yàn)證 Spring MVC 日期格式

        Spring MVC Date format validation with JSR303(使用 JSR303 驗(yàn)證 Spring MVC 日期格式)

          • <legend id='BVZ0o'><style id='BVZ0o'><dir id='BVZ0o'><q id='BVZ0o'></q></dir></style></legend>
            <i id='BVZ0o'><tr id='BVZ0o'><dt id='BVZ0o'><q id='BVZ0o'><span id='BVZ0o'><b id='BVZ0o'><form id='BVZ0o'><ins id='BVZ0o'></ins><ul id='BVZ0o'></ul><sub id='BVZ0o'></sub></form><legend id='BVZ0o'></legend><bdo id='BVZ0o'><pre id='BVZ0o'><center id='BVZ0o'></center></pre></bdo></b><th id='BVZ0o'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BVZ0o'><tfoot id='BVZ0o'></tfoot><dl id='BVZ0o'><fieldset id='BVZ0o'></fieldset></dl></div>

                • <bdo id='BVZ0o'></bdo><ul id='BVZ0o'></ul>
                  <tfoot id='BVZ0o'></tfoot>

                  <small id='BVZ0o'></small><noframes id='BVZ0o'>

                    <tbody id='BVZ0o'></tbody>
                • 本文介紹了使用 JSR303 驗(yàn)證 Spring MVC 日期格式的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在使用帶有 JSR303 的 Spring MVC 進(jìn)行輸入驗(yàn)證.

                  I'm using Spring MVC with JSR303 to do my input validation.

                  我創(chuàng)建的表單有幾個(gè)日期字段,這些字段綁定到支持表單的對(duì)象中的 Date 對(duì)象.我正在使用 JSR303 使用 @Future 對(duì) Date 進(jìn)行驗(yàn)證.我也在使用 @DateTimeFormat(pattern="dd/MM/yyyy"),(我知道這不是驗(yàn)證).

                  A form I've created has a couple of date fields that are bound to Date objects within the object backing the form. I'm using JSR303 to do the validation for the Date using @Future. I'm also using @DateTimeFormat(pattern="dd/MM/yyyy"), (I know it's not validation).

                  如何驗(yàn)證表單上 String 的日期格式?如果我將其他必填字段留空 (@NotEmpty) 并以dd/MM/yy"形式輸入無(wú)效日期,它會(huì)在重新轉(zhuǎn)換為dd/MM/yyyy"演示文稿(例如 12/03/12 重新呈現(xiàn)為 12/03/0012).這意味著我將在我的系統(tǒng)中獲得 duff 數(shù)據(jù).如果我輸入aaa",我會(huì)得到一個(gè)轉(zhuǎn)換異常.格式正確的 String 被轉(zhuǎn)換為 Date 對(duì)象.

                  How do I validate the date format of the String on the form? If I leave the other required fields blank (@NotEmpty) and enter a non-valid date in the form 'dd/MM/yy' it gets converted to 'dd/MM/yyyy' on re-presentation (e.g. 12/03/12 is re-presented as 12/03/0012). Which means I will get duff data in my system. If I enter "aaa" for I get a conversion Exception. Correctly formatted Strings get converted to Date objects.

                  Date 字段的必填字段"注釋還應(yīng)該是 @NotNull 還是 @NotEmpty?

                  Additionally should the 'required field' annotation for Date fields be @NotNull or @NotEmpty?

                  非常感謝您提供的任何建議.

                  Many thanks in advance for any advice provided.

                  推薦答案

                  謝謝拉爾夫.我做了一些進(jìn)一步的挖掘并想出了這個(gè)(在我的表單控制器中):

                  Thanks Ralph. I did some further digging around and came up with this (Which goes in my form controller):

                      @InitBinder
                      public void initBinder(WebDataBinder binder) {
                  
                  
                      String format = "dd/MM/yyyy";
                      SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                      dateFormat.setLenient(false);
                      CustomDateEditor customDateEditor = new CustomDateEditor(dateFormat,true,format.length());
                  
                      binder.registerCustomEditor(Date.class, customDateEditor);
                      }
                  

                  屬性文件具有以下鍵:

                  typeMismatch.java.util.Date :一些很好的平靜的安慰信息,以幫助所有疏忽的用戶(hù)

                  typeMismatch.java.util.Date : Some nice calm reassuring message to assist all negligent users

                  也許還有其他一些方法可以做到這一點(diǎn),但現(xiàn)在就可以了.

                  Maybe there are some other ways to do this but this will do for now.

                  這篇關(guān)于使用 JSR303 驗(yàn)證 Spring MVC 日期格式的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)
                    <tbody id='J3QFw'></tbody>

                  1. <legend id='J3QFw'><style id='J3QFw'><dir id='J3QFw'><q id='J3QFw'></q></dir></style></legend>

                    <small id='J3QFw'></small><noframes id='J3QFw'>

                        <bdo id='J3QFw'></bdo><ul id='J3QFw'></ul>
                      • <tfoot id='J3QFw'></tfoot>
                        <i id='J3QFw'><tr id='J3QFw'><dt id='J3QFw'><q id='J3QFw'><span id='J3QFw'><b id='J3QFw'><form id='J3QFw'><ins id='J3QFw'></ins><ul id='J3QFw'></ul><sub id='J3QFw'></sub></form><legend id='J3QFw'></legend><bdo id='J3QFw'><pre id='J3QFw'><center id='J3QFw'></center></pre></bdo></b><th id='J3QFw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='J3QFw'><tfoot id='J3QFw'></tfoot><dl id='J3QFw'><fieldset id='J3QFw'></fieldset></dl></div>

                            主站蜘蛛池模板: 一级特黄色毛片 | 国产精品高潮呻吟久久 | 热久久性| 久久久久网站 | 久久亚洲国产精品 | 国产激情一区二区三区 | 岛国av免费观看 | 国产一区二区三区www | 国产精品国产精品国产专区不卡 | 成人午夜视频在线观看 | 国产一区二区精品在线观看 | 一区二区三区在线 | av在线免费观看网站 | 国产精品成人久久久久 | 亚洲欧美一区二区三区在线 | 国产yw851.c免费观看网站 | 国产精品免费观看 | www.黄色片视频 | 农村妇女毛片精品久久久 | 欧美成人h版在线观看 | 欧美天堂| 999久久久久久久久6666 | 午夜视频在线观看网站 | 天天综合国产 | 日韩在线视频观看 | 午夜电影日韩 | 久久久久久久久国产精品 | 中文字幕一区二区三区四区不卡 | 怡红院成人在线视频 | av在线播放国产 | 91在线观看免费 | 亚洲精品一二三 | 精品久久亚洲 | 91在线成人| 国产精品久久久久久久模特 | 久久久www成人免费无遮挡大片 | 91在线成人| 久久精品亚洲精品国产欧美kt∨ | 国产精品久久久久久久 | 在线色 | 免费精品|