【问题标题】:JSP page javax.el.PropertyNotFoundException [duplicate]JSP 页面 javax.el.PropertyNotFoundException [重复]
【发布时间】:2012-08-29 16:13:04
【问题描述】:

我的视图模型如下所示:

public class HomePageViewModel {
    private List<AlertViewModel> alertViewModels;
    public List<AlertViewModel> getAlertViewModels() { 
        return alertViewModels;
    }
    public void setAlertViewModels(List<AlertViewModel> alertViewModels) {
        this.alertViewModels = alertViewModels;
    }

    public HomePageViewModel(){
        alertViewModels = new ArrayList<AlertViewModel>();
    }
}

AlertViewModel 如下所示:

public class AlertViewModel {
    private String id;
    public String getId(){
        return id;
    }
    public void setId(String id){
        this.id = id;
    }

    public AlertViewModel(){
        id = "";
    }
}

JSP 看起来像这样:(viewModel 是 HomePageViewModel)

<table border="1">
    <tr>
    <th>Id</th>
    </tr>

    <c:forEach items="${viewModel.AlertViewModels}" var="alert">
      <tr>
      <td>${alert.Id}</td>
      </tr>
    </c:forEach>    
</table>

但我收到此错误:

HTTP ERROR 500

Problem accessing /. Reason:

Could not find property AlertViewModels in class viewmodels.HomePageViewModel
Caused by:

javax.el.PropertyNotFoundException: Could not find property AlertViewModels in class viewmodels.HomePageViewModel

我做错了什么?我认为我的 get/set 正确吗?

【问题讨论】:

    标签: jsp properties javabeans propertynotfoundexception


    【解决方案1】:

    getter 名称是 getAlertViewModels(),因此您应该引用 alertViewModels(小写 A)。

    【讨论】:

      猜你喜欢
      • 2012-06-22
      • 2014-06-30
      • 2011-05-06
      • 1970-01-01
      • 2016-05-05
      • 2013-02-01
      • 2014-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多