开发者

<jsp:getProperty> strange behaviour

I have a bean class whit set/get methods and from a JSP page when I try to get a property with:

  1. <jsp:getProperty name="p" property="firstName"></jsp:getProperty> and the method in the bean is named as: getFirstName or getfirstName the property is returned;

  2. <jsp:getProperty name="p" property="FirstName"></jsp:getProperty> and the method in the bean is named as: getFirstName or getfirstName the property is not return开发者_如何学Goed and I have this exception: org.apache.jasper.JasperException: PWC6054: Cannot find any information on property 'FirstName' in a bean

Why? I know that for bean rules when I write a property name the container try to find a getter or setter method that start with get or set and then continues with the property name indicated (no matter if it starts with the first letter capitalized???)

Thanks.


Java beans rely on naming conventions for introspection, see the spec here:

http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html

You'll be most interested in section 8.3 (page 55 in the PDF).


No you are worng,

when you create getter and setter methods method will be created as getXxxx() and setXxxx() if the attribute is private String xxxx;

So please follow the code convention while creating getter and setter methods. this will resolve the issue.

So ur property will be lowercase letter as first_name in ur bean class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜