开发者

Data binding of type of Date Class. "2010/01/02" binds correctly, but "2010-01-02" does not

开发者 https://www.devze.com 2023-02-11 22:21 出处:网络
I found that, by default when I using Spring MVC, \"2010/01/02\" binds correctly, but \"2010-01-02\" does not.

I found that, by default when I using Spring MVC, "2010/01/02" binds correctly, but "2010-01-02" does not.

I know Spring has some useful binding mechanisms like initBinder. However, in this question I want to know where is the rule defined. Do开发者_如何学JAVAes anyone know that for example RFC documents of HTTP or Spring references.


It's just coincidence.

Spring MVC can implicitly convert input parameters to model objects via their single-argument constructor that takes String (if model objects have such constructors). Date has this constructor, though it's deprecated, so that this behaviour is determined by behaviour of that constructor.

0

精彩评论

暂无评论...
验证码 换一张
取 消