- There are two ways to configure managed beans, one is Using the "faces-config.xml" file, another is using "annotations".
- So in this demo, I want to configure beans using annotations in MyEclipse, but it didn't work.
- Here is the code:
1.UserBean.java
public class UserBean {
String userid;
String password;
@Named("userBean")
@RequestScoped
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}}
2.Login.xhtml the page users enter the id and password
3.Welcome.xhtml when user click the submit button, the page comes
4.faces-config.xml faces-config.xml
As you can see, I didn't configure the managed bean in the "faces-config.xml" file, I just use "@Named("userBean")" and "@RequestScoped" in my "UserBean.java" file to configure the bean.
1.I open the login.xhtml on the website
2.When I click the button to submit the data, it comes up this page:
I started to learn JSF these days, there are many confused things I need to figure out, thanks a lot if you can give me some notes or guidance on this question ^_^
(Ps.This is the first question I ask on stackoverflow, so I couldn't upload pictures directly, if you cannot see the pictures by hperlinks, please let me know.Thanks!)