The convention used is to return the uncapitalized short name of the Class, according to JavaBeans property naming rules: So, com.myapp.Product becomes product; com.myapp.MyProduct becomes myProduct; com.myapp.UKProduct becomes UKProduct.
我查看了 Suns 网站以查找定义,但没有找到。我想知道开头有一个以上大写字符的名称规则。如果第二个字符也是大写,那么第一个字符是大写的规则吗?
背景是,我想根据对象的类型自动生成用于 HTML 模板的变量名。示例:类:SomeName --> 对象:someName。
最佳答案
http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-138795.html
还有一个 direct link to the (PDF) specification .
链接文档中的第 8.8 节标题为“推断名称的大写”,并简要概述了属性名称的派生方式。
关于java - JavaBean 属性命名约定在哪里定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1991316/