久久久久久久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 驗證 Spring MVC 日期格式

        Spring MVC Date format validation with JSR303(使用 JSR303 驗證 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 驗證 Spring MVC 日期格式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用帶有 JSR303 的 Spring MVC 進行輸入驗證.

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

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

                  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).

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

                  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 字段的必填字段"注釋還應該是 @NotNull 還是 @NotEmpty?

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

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

                  Many thanks in advance for any advice provided.

                  推薦答案

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

                  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 :一些很好的平靜的安慰信息,以幫助所有疏忽的用戶

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

                  也許還有其他一些方法可以做到這一點,但現在就可以了.

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

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

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 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>

                            主站蜘蛛池模板: 中文字幕在线观 | 在线一区 | 美女天堂在线 | 久久午夜影院 | 成年人网站免费 | 台湾佬成人网 | 黄色一级毛片 | 91久久国产综合久久 | 国产高清精品一区二区三区 | 免费成人av网站 | 在线播放国产一区二区三区 | 久久久久国产一区二区三区 | 香蕉婷婷| 免费在线一区二区 | 99re在线视频| h视频在线免费看 | 黄色一级大片在线观看 | 色综合天天天天做夜夜夜夜做 | 国产激情一区二区三区 | 日韩电影免费观看中文字幕 | 浮生影院免费观看中文版 | 日韩精品区 | 久久免费精品视频 | 亚洲第一网站 | 欧美午夜一区二区三区免费大片 | 一区二区在线 | 久久9久 | 九九免费在线视频 | av免费看在线 | 在线视频一区二区三区 | 色av一区二区 | 日韩av在线一区二区三区 | 黑人巨大精品 | 久久久91精品国产一区二区三区 | 理论片午午伦夜理片影院 | 97日韩精品 | 欧美成人免费在线 | 97碰碰碰| 久久久精品网站 | 婷婷桃色网 | 成人av电影免费在线观看 |