springmvc使用spring自带日期类型验证
生活随笔
收集整理的這篇文章主要介紹了
springmvc使用spring自带日期类型验证
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
控制器
@Controller public class MyController {// 處理器方法@RequestMapping(value = "/first.do")public String doFirst(Date birthday, int age) {return "/jsp/two.jsp";}// 自定義一個方法 @InitBinderpublic void initBinder(WebDataBinder binder) {DateFormat df = new SimpleDateFormat("yyyy-MM-dd");//0需要返回的類型,1傳入一個帶格式的df,2允許為空binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true));} }?
轉(zhuǎn)載于:https://www.cnblogs.com/cnsdhzzl/p/6097922.html
總結(jié)
以上是生活随笔為你收集整理的springmvc使用spring自带日期类型验证的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: github Android-Unive
- 下一篇: Linux下的删除命令