我正在尝试使用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>