0
我在我的Action中使用validate(),這裏是我的validate()方法的外觀。Struts2中的重複驗證錯誤
public void validate() {
logger.info(".validate() : userName=["+userName+"] & password=["+password+"]");
clearActionErrors();
if(userName==null || userName.length()==0){
addFieldError("userName", "User Name is required.");
}
if(password==null || password.length()==0){
addFieldError("password", "Password is required.");
}
}
而在jsp我加入了部分。
錯誤按預期顯示。如何當我刷新頁面,我看到錯誤兩次。此外,如果我繼續刷新它的錯誤消息得到顯示的次數增加1.
不知道這是什麼問題。
我試着調用clearActionErrors();在我的execute()方法中,似乎沒有解決問題。
感謝
additionaly需要你的jsp和struts配置文件的代碼 –
你是否使用spring插件來創建動作實例??? –
我和Umesh在一起;這幾乎總是由於使用Spring和創建單例而不是原型bean。 –