【发布时间】:2018-05-09 07:49:12
【问题描述】:
- 有两种配置托管bean的方法,一种是使用“faces-config.xml”文件,另一种是使用“注解”。
- 所以在这个演示中,我想在 MyEclipse 中使用注解配置 bean,但是没有成功。
- 这里是代码:
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
如您所见,我没有在“faces-config.xml”文件中配置托管bean,我只是在“UserBean.java”中使用“@Named("userBean")”和“@RequestScoped” " 文件来配置 bean。
1.我在网站上打开login.xhtml
2.当我点击按钮提交数据时,它会出现这个页面:
我这几天开始学习JSF,有很多困惑的地方需要弄清楚,如果你能给我一些关于这个问题的笔记或指导,非常感谢^_^
(Ps.这是我在stackoverflow上问的第一个问题,所以我无法直接上传图片,如果您无法通过hperlinks看到图片,请告诉我。谢谢!)
【问题讨论】:
标签: jsf cdi managed-bean propertynotfoundexception