javax.el.PropertyNotFoundException: Property 'foo' not readable on type java.lang.Boolean

后端 未结 2 874
一整个雨季
一整个雨季 2020-12-15 04:09

I have a class which looks something like this:

public class ScoreDefinition {

    protected Boolean primary;

    public Boolean isPrimary() {
        retu         


        
相关标签:
2条回答
  • 2020-12-15 04:49

    You can use a call directly to method score.isPrimary() like this:

    <c:forEach var="score" items="${scores}">
    <input type="checkbox"
           value="${score.isPrimary()}"
           name="someName"
           class="textField"/>
    </c:forEach>
    
    0 讨论(0)
  • 2020-12-15 05:05

    The is prefix is for boolean only, not for Boolean.

    You have 2 options:

    1. Use boolean instead of Boolean.

    2. Or, rename method isPrimary() to getPrimary().

    As to JAXB blunder of autogenerating the wrong method, you need to upgrade to at least JAXB 2.1.13 or to add -B-enableIntrospection to the wsimport call as per this JAXB documentation.

    See also:

    • JavaBeans specification - Chapter 8.3.2
    • How does Java expression language resolve boolean attributes? (in JSF 1.2)
    • JSF 2 checkboxes and boolean getters
    0 讨论(0)
提交回复
热议问题