An unusual error occurred when using the expression language in JSP for a specific property only.

I have this unusual scenario:

I have a VO registration with several properties and getter settings for this. For example, cityor bCitywith their methods of obtaining getCity()andgetBCity()

In JSP, I tried to display the value of these properties using scripts, <%=registrationVO.getCity()%>and < %=registrationVO.getBCity()%>, it works fine. But I replaced the expression language, ${registrationVO.city}and ${registrationVO.bCity} I got an error stating that the "bCity" property was not found in the VO registration. I used scriplet for bCity again, I got the result.

I noticed that this is due to the naming convention. "If the second character of the property is the letter Capital, we cannot use the language of expressions." I tried with many differences, this is what I learned.

Please check this scenario, I do not know how right or wrong I am.

Thanks DJ

+3
source share
1 answer

If the getter method property name begins with at least two uppercase characters, you also need to use all those uppercase characters in the EL property name. In your particular case, you need to replace it with ${registrationVO.BCity}. This is stated in chapter 8.8 of the Javabeans spec . Here is an excerpt from a chapter (emphasis added):

8.8 Capitalization of prospective names.

, , . Java- mixedCase, .

Java- , . , .

, Java-, . , , , . , ,

  • "FooBah" "fooBah"
  • "Z" "z"
  • "URL" "URL"

Introspector.decapitalize, .

, . , birthCity ( , ), ${registrationVO.birthCity}.

+7
source

Source: https://habr.com/ru/post/1731547/


All Articles