Java – an unexpected error occurred when using the expression language only for a specific attribute in JSP – please check this item
I have this unusual situation:
I have a registrationvo, which has few properties and getter setter For example, city or bCity and its getter methods getcity() and getbcity()
In JSP, I try to use scriptlets to display the values of these attributes, <% = registrationvo Getcity()% > and <% = registrationvo Getbcity()% >, it works normally But I replaced the same with the expression language, ${registrationvo. City} and ${registrationvo. BCity} I got an error saying that the attribute "bCity" was not found in the registration I used a scriptlet for bCity again, and I got the output
I observe it because of naming conventions If the second character of the property is a capital letter, we can't use expression language I've tried many differences, and that's what I found
Please check the scene. I don't know whether my conclusion is right or wrong
Thank you, DJ
Solution
If the property name of the getter method starts with at least two uppercase characters, you also need to use all these uppercase characters in the El property name In your specific case, you need to replace it with ${registrationvo. BCity} This is described in detail in Chapter 8.8 of the JavaBeans spec This is an excerpt from this chapter (emphasizing my):
In other words, I'd rather rename them to something more reasonable Maybe birthcity (if I guessed right), then you can use ${registrationvo. Birthcity} well