1. 程式人生 > >javax.el.PropertyNotFoundException: Property 'XXX' not readable

javax.el.PropertyNotFoundException: Property 'XXX' not readable

使用spring框架,自己組裝了一個資訊搭載類扔到JSP中渲染,大致是這樣:

UserBasicInfo userInfo = new UserBasicInfo(user);

以及

<img id="user_avatar" src="${userInfo.avatar}" class="img-responsive col-md-6" alt="使用者頭像"/>

這時候執行時就會出現標題中的錯誤,UserBasicInfo是pojo,是放在UserController.java中的一個非public類。試過把他做成bean仍會有這個錯誤,之後考慮spring是使用代理來做這些事情的,預設訪問許可權的類spring可能訪問不到,就把這個類單獨做成一個檔案做成public的,問題解決。