카테고리 없음
[자바] Struts2 유효성 검사는 정규식에서만 작동하지 않습니다.
행복을전해요
2021. 1. 24. 06:12
매개 변수는이 regexExpression
아니 어야합니다 expression
.
http://struts.apache.org/development/2.x/docs/regex-validator.html
특정 필드의 오류를 표시하려면 fieldName
속성을 사용하십시오 . 예 :
<s:fielderror fieldName="cogname" />
주의 <s:form>
의 validate
속성과 관련 클라이언트 측 유효성 검사; 서버 측의 유효성 검사와 관련이 없습니다.
2 차 문제 (하지만 다른 질문 인 imho 여야 함)의 경우, 그 이유는 필드 자체 아래에 필드 이름과 함께 fielderror를 넣어야하기 때문입니다.
기본 Struts 테마와 같은 특정 Struts 테마를 사용하면 자동으로 처리됩니다.
Simple Theme를 사용하고있을 가능성이 있으므로 직접 수행해야합니다 (단락 대신 레이블을 사용해야 함).
<label for="idCognome">
<s:text name="label.cognome" />
</label>
<s:textfield name="cognome" id="idCognome" value="%{anagraficaVDR.cognome}" />
<s:fielderror fieldName="cognome"/>
필드는 "cognome"이라는 필드 오류가 발견되는 경우에만 렌더링됩니다.
출처
https://stackoverflow.com/questions/22019803