The attribute naming does not comply with the javaBean specification, resulting in no value obtained after version upgrade

As shown below:
  The iName attribute defined as follows exists in struts2 Action, strust2 is upgraded from 2.3.15.x to the latest version, eclipse uses 4.4.2, the background iName attribute cannot get the value passed from the front desk, and it is empty.
public class XxxxAction {
   private int iName;
   private int age;


	public int getIName() {
		return iName;
	}

	public void setIName(int iName) {
		this.iName = iName;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}
   
   
}


After consulting the data, we can see:
1. For the general property <propertyName>, the first word of the property name is lowercase and the number of lowercase letters after it is greater than 1, and the first letter of the second word is uppercase. The corresponding getter/setter method name is: get /set + <PropertyName>(), that is, the first letter of the first word of the property name is changed to uppercase, followed by "get" or "set" prefix.
For example: userName getUserName() setUserName()
2. For the boolean type <propertyName>, the getter/setter method can be written according to the rules of conventional properties, and the getter method can be replaced by the form of is + <PropertyName>().

3. For the unconventional attribute <pName>, the first word of the attribute name is lowercase and the number of letters is equal to 1, and the first letter of the second word is uppercase.
    The corresponding getter/setter method name of the old Eclipse version (do not know which version started) can be: get/set + <PName>(), that is, the first letter of the first word is changed to uppercase, followed by "" get" or "set" prefix
 

Summary :

1. The javaBean property naming convention is named according to the javaBean specification.
2. The first word of the property name should try to avoid using a letter: such as eBook, eMail.
3.
With the continuous improvement of software versions such as jdk, eclipse, struts2, spring, etc., the problems in the lower version may be solved in the higher version, and the original normal code of the lower version may no longer be supported in the higher version environment. The pit encountered is very big, and it has been checked that the value caused by the upgrade of the framework cannot be injected. Summarize the lessons learned here.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326094294&siteId=291194637