Điều kiện Java sau đây chuyển thành s:if test="..."
trong struts2 như thế nào?struts2: enum in IF
if(company.getAffiliateId().asInt() != com.foo.bar.Affiliates.XYZ.asInt()){
// do something
}
company.getAffiliateId() lợi nhuận BigDecimal
com.foo.bar.Affiliates là một enum
này không hoạt động:
<s:if test="%{company.affiliateId.asInt() != com.foo.bar.Affiliates.XYZ.asInt() }">
alert("do something");
</s:if>
Tôi nghĩ lớp enum được tạo ra dựa trên một bảng cơ sở dữ liệu. Không có phương thức tĩnh trong nó: id int riêng; Chi nhánh riêng tư (int id) {this.id = id; } Công khai BigDecimal asBigDecimal() {return BigDecimal.valueOf (id); } int công khai asInt() {return id; } –
Hmm .. bạn nói đúng. Đã xóa phần sai câu trả lời của tôi. –