How to implement validations using annotations in struts2 in action that implements ModelDriven interface?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 07:40:25

You need to add @VisitorFieldValidator annotation to user getter inside your action class.

@VisitorFieldValidator(appendPrefix = false)
public User getUser() {
  return user;
}

Note that you need to set appendPrefix to false if your are using field names without user. prefix in JSP.

Also, you are probably want @RequiredStringValidator not @RequiredFieldValidator inside your bean.

@RequiredStringValidator(message = "User Name field is empty.")
@Column(name="USER_NAME")
public String getName() {
  return name;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!