我在 Grails 2.5.3 中有一个名为 EQuestionController
的 Controller 和一个名为 EQuestionService
的服务。
当我调用 Controller 时,我需要将其作为 /EQuestion
执行,而我原本希望将其调用为 /eQuestion
,但在这种情况下会出现 404 错误.
当我将服务注入(inject) Controller 时,当我期望将其注入(inject)为 def eQuestion
时,我需要将其作为 def EQuestion
执行,但在本例中它是空
。
用前两个字母大写来命名 Controller 或服务不是正确的吗?
最佳答案
此命名行为在 java bean 规范 ( http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec ) 中定义
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone.
So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
因此,EQuestionService
的 bean 变为 EQuestionService
关于grails - Controller 和服务的前两个字母大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38048105/