1. First, you build the xhtml file
#{msgs.namePrompt}:
#{msgs.agePrompt}:
The correct label should be declared as:
and the correct error message should be declared as:
#{msgs.agePrompt}:
with “for” as same as “name” of the target.
2. and then build user.java
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@Component("user")
@Scope("session")
public class User implements Serializable {
private String name;
private String age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
}