0
액션 클래스에서 나는 List
을 다음과 같이 가지고 있습니다.Struts2에서 빈 Collection의 유효성을 검사하는 방법은 무엇입니까?
private List<SomeEntity>entity=new ArrayList<SomeEntity>();
public List<SomeEntity> getEntity()
{
this.entity=someService.getList(); //Initialize after some ugly conditional checks, lazy loading.
return this.entity;
}
//Setter is not required in this case.
어떤 이유로 든 선언 장소에서 초기화해야합니다. 이 List
이후
은 작업 방법에 null
(그리고 사실,이 경우, null
할 수 없다), 다음과 같은 검증,
@Validations(
requiredFields={
@RequiredFieldValidator(fieldName="entity", type=ValidatorType.FIELD, key="key.required")})
public String doAction()
{
return ActionSupport.SUCCESS;
}
작동하지 않습니다하지 않습니다 (목록에 객체가 없기 때문에 유효성 검사 오류가 발생하기를 기대합니다. 크기는 0입니다.)
그래서이 필드의 유효성을 검사하는 방법 entity
, 크기가 0 인 경우?
저는 Struts 2.3.16을 사용합니다.