FeatureDetail.java
public class FeatureDetail{
private String featureId;
private String featureName;
// Their getter and setter methods.
@Override
public int hashCode() {
return featureId.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FeatureDetail other = (FeatureDetail) obj;
if (featureId == null) {
if (other.featureId != null)
return false;
} else if (!featureId.equals(other.featureId))
return false;
return true;
}
}
我有以下类(IndexAction.java)
class IndexAction extends ActionSupport {
private List<FeatureDetail> selectedFeatures;
private List<FeatureDetail> features;
// Getter and setter methods for features and selectedFeatures
}
功能是所有功能的列表。 selectedFeatures是所有选定功能的列表。 这两个列表都有FeatureDetail对象。
在我的jsp index.jsp
中<s:iterator value="features" var="feature">
<label><s:property value="#feature.featureName"/></label>
<s:if test="#feature in selectedFeatures">
<input type="checkbox" checked="checked"/>
</s:if>
<s:else>
<input type="checkbox"/>
</s:else>
</s:iterator>
我的问题是,即使selectedFeatures列表中有两个属于特征的对象(FeatureDetail对象),也只会检查一个复选框。
实际要求是,我希望选中复选框以查看selectedFeatures列表中的值。