fix(structs): resolve calc input result and add utf-8/meta plus form validation
This commit is contained in:
@@ -68,6 +68,22 @@ public class UserFormAction extends ActionSupport {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.getName() == null || user.getName().trim().isEmpty()) {
|
||||
addFieldError("user.name", "姓名不能为空");
|
||||
}
|
||||
if (user.getEmail() == null || !user.getEmail().contains("@")) {
|
||||
addFieldError("user.email", "邮箱格式不正确");
|
||||
}
|
||||
if (user.getAge() == null || user.getAge() < 1 || user.getAge() > 120) {
|
||||
addFieldError("user.age", "年龄必须在 1 到 120 之间");
|
||||
}
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public User getUser() { return user; }
|
||||
public void setUser(User user) { this.user = user; }
|
||||
|
||||
Reference in New Issue
Block a user