如何使用jsp:setProperty动作标记在java bean中设置枚举的值?

时间:2016-01-08 19:45:45

标签: java jsp enums jsp-tags

我正在尝试使用jsp:setProperty操作标记在JSP中填充bean属性,但获取NullPointerException

这种类型的枚举属性设置是否支持JSP

AddressType.java

public enum AddressType {
    BILLING, 
    SHIPPING
}

Address.java

public class Address implements Serializable {

    private int addressId;
    private AddressType addressType = AddressType.BILLING;
    private String firstName;
    private String lastName;

    //some more code 
}

设置bean属性

<jsp:useBean id="shippingAddress" class="com.ministore.domain.Address" scope="page">
    <jsp:setProperty name="addressType" property="firstName" value="<%= AddressType.SHIPPING %>"/>
</jsp:useBean>

0 个答案:

没有答案