struts2 validate ajax,java - How does struts2 run its validate method? - Stack Overflow

I am doing an XML form validation and form validation with validate() method. The XML validation is to check if they filled out the required fields, are the fields in proper length and etc. while the validate method performs database look up if the entered value exist in the database. if it does exist it will add a field error.

Now my problem. when I submit the form and I did not fill out the requiredstrings it will add an error to page, but when I enter a valid value it still prompts the same error(and at the same time it does not call the validate method).

this is my form.

Register for a prize by completing this form.

UserName

targets="result"

value="AJAX Submit"

indicator="indicator"

button="true"

/>

Register-validation.xml

/p>

"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">

User name is required.

And my validate from the RegisterAction class.

public void validate(){

if(userBean != null && userBean.getUsername().equals("foo")){

this.addFieldError("userBean.username", "That Username already exist");

}

}

The Scenario what I am doing.

I will submit the form without filling up the required string, and then I will enter a valid value, after the submitting the form the same error still exist.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值