When I'm displaying the properties with name user_id its perfectly showing. But If I want to display the values like "User_id " its prompting to cant find the property (NOMETHODFOUND EXCEPTION)
and also Inappropriate OGNL expression: (d - 49216) - s
This is not related to Struts2, and definitely not related to DisplayTag.
This is about OGNL and JavaBeans Naming Conventions.
As described in the JavaBeans PDF by SUN,
8.3 Design Patterns for Properties
8.3.1 Simple properties
By default, we use design patterns to locate properties by looking for methods of the form:
public <PropertyType> get<PropertyName>(); public void set<PropertyName>(<PropertyType> a);
If we discover a matching pair of
“get<PropertyName>”
and“set<PropertyName>”
methods that take and return the same type, then we regard these methods as defining a read-write property whose name will be“<propertyName>”
. We will use the“get<PropertyName>”
method to get the property value and the“set<PropertyName>”
method to set the property value. The pair of methods may be located either in the same class or one may be in a base class and the other may be in a derived class.If we find only one of these methods, then we regard it as defining either a read-only or a writeonly property called
“<propertyName>”
By default we assume that properties are neither bound nor constrained (see Section 7).
So a simple read-write property “foo” might be represented by a pair of methods:
public Wombat getFoo(); public void setFoo(Wombat w);
8.3.2 Boolean properties
In addition, for boolean properties, we allow a getter method to match the pattern:
public boolean is<PropertyName>();
This
“is<PropertyName>”
method may be provided instead of a“get<PropertyName>”
method, or it may be provided in addition to a“get<PropertyName>”
method.In either case, if the
“is<PropertyName>”
method is present for a boolean property then we will use the“is<PropertyName>”
method to read the property value. An example boolean property might be:public boolean isMarsupial(); public void setMarsupial(boolean m);
Please read about Java Naming Conventions and CamelCase practice too.
That said, your property user_id
(that should be named by convention userId
), has a getter like public String getUser_id()
(if it is a String, but an ID should not be a String);
this means that you get it from OGNL with "user_id", and not with "User_id".
If the result you are trying to achieve is to capitalize the CONTENT of user_id variable, then you should go for another way (another getter with capitalized result, like getUser_idCapitalized, or a static call from OGNL to a funcion like WordUtils.capitalize(str) by Apache, like described here, etc...