java el expression reports null pointer exception (nullpointexception)

Recently, when using el expressions, int variables have been used, because, in many cases, variables will not be assigned initial values. After considering it later, the declaration should be changed from int to integer, and a null pointer will always be reported after the change. Exception, check carefully later, in my getter and setter methods, I still set int or return int. I have tested it before, declaring the integer variable, without initialization, and returning through int will report a null pointer exception. The reason should be an error when Integer (null) is converted to int. Therefore, the data in the background of the el expression must be of the same class or the same basic type, (the basic type of the numeric type returns 0 or 0.0, and the char type returns the null character, what is in it, no detailed study, boolean type variable Return false), if you need no initial value in the foreground, you need to use object data (for example, the bound input box does not display any data, that is, the data is null)

2018-05-04 Update

In fact, the EL expression calls the get method to get the value.

Guess you like

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