加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java-Spring MVC是否使用setter方法设置ModelAttribute对象的属

发布时间:2020-12-15 01:20:44 所属栏目:大数据 来源:网络整理
导读:Spring MVC是否使用getter和setter来设置ModelAttribute对象的值?能否请你引用我的话说.如果不是,我们如何强制Spring MVC使用setter设置模型对象的属性? 谢谢. 最佳答案 我不知道这是否真的可以回答问题,但是我在文档中找到了这句话: Command or form obj

Spring MVC是否使用getter和setter来设置ModelAttribute对象的值?能否请你引用我的话说.如果不是,我们如何强制Spring MVC使用setter设置模型对象的属性?

谢谢.

最佳答案
我不知道这是否真的可以回答问题,但是我在文档中找到了这句话:

Command or form objects to bind request parameters to bean properties (via setters) or directly to fields,with customizable type conversion,depending on @InitBinder methods and/or the HandlerAdapter configuration. … The ModelAttribute annotation can be used on a method argument to customize the model attribute name used.

这似乎暗示着将使用setter(如果可用),并直接更新字段作为后备.

但是,如果您想要一个明确的答案,请查看源代码.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读