내 응용 프로그램에 Struts 1.2를 사용 중입니다. 폼에서 사용자가 제공 한 입력에 대한 유효성 검사를하고있는 유효성 검사 메서드가 있습니다.Struts 오류 메시지가 UI에 표시되지 않음
@Override
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
System.out.println("Validating the Form...");
ActionErrors errors = new ActionErrors();
if(userName != null && userName.length() <= 0)
errors.add("userName",new ActionError("Invalid UserName"));
return errors;
}
사용자 이름은 사용자가 wntered되지 않은 경우, 상기 에러 메시지는 상기 UI에 표시한다 : 다음 사용자가 제공 userName
위한 코드이다. 아래는 내가 위의 오류 메시지를 표시하기위한 JSP 파일에 사용 된 코드입니다 :
<logic:messagesPresent property="userName">
<html:messages id="userName" property="userName">
<bean:write name="userName"/>
</html:messages>
</logic:messagesPresent>
는하지만 오류 메시지가 표시되지 않았다.
나는이 대안을 시도했지만이 또한 작동하지 않았다 : 내가 코드를 디버깅 할 때
<logic:messagesPresent property="userName">
<html:errors property="userName" /><html:errors/>
</logic:messagesPresent>
에서, validate
방법은 form
에서 실행지고하고있다 이후 execute
방법은 트리거되지 않습니다 유효성 검증 오류. UI에는 오류 메시지가 표시되지 않습니다. 친절하게도이 문제를 해결하는 방법을 알려주세요.
감사합니다. 문제가 해결되었습니다. – user182944