我是JSF的新手,我已阅读了几篇教程,但是,出于某种原因,当我尝试将数据从表单传输到另一个页面时,它返回null。
这是豆
package stateless;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.Dependent;
@Named(value = "jsfbean")
@Dependent
public class jsfbean {
@EJB
private MyuserFacadeRemote myuserFacade;
private String username;
private String password;
private String message;
/**
* Creates a new instance of jsfbean
*/
public jsfbean() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMessage() {
return "Hello "+ username;
}
public void setMessage(String message) {
this.message = message;
}
}
这是主页
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Index</title>
</h:head>
<h:body>
<h:form>
<p>Login</p>
<h:inputText value="#{jsfbean.username}"/>
<h:commandButton action="result" value="Results Page"/>
</h:form>
</h:body>
</html>
在结果页面上,唯一存在的是#{jsfbean.message} 希望有人可以提供帮助
答案 0 :(得分:0)
我认为@dependent范围不起作用。尝试会话范围。