我正在使用3.0 M3。当我在faces-config.xml中声明我的托管bean时,它工作得很好,但是当我用注解@托管bean@请求作用域尝试相同的代码时,它显示目标不可达。
我也尝试了2.2,但它再次显示相同的问题。我使用的是glass fish v3
@ManagedBean
@SessionScoped
public class Profile implements Serializable{
private String userId;
private String password;
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}下面是我对它们的称呼
<h:form>
<p:panel style="margin-top: 200px;margin-left: 300px;margin-right: 300px;" header="Welcome">
<h:outputText value="Your Code ? "/>
<h:inputText required="true" requiredMessage="Enter user id" value="#{Profile.userId}"/>
<h:outputText value="Password "/>
<h:inputSecret required="true" requiredMessage="Enter password id" value="#Profile.password}"/>
<h:commandButton action="#{Profile.varify}" value="Next"/>
</p:panel>
</h:form>发布于 2011-10-24 19:24:37
配置文件应为小写,并检查密码行上的语法
发布于 2011-10-24 19:36:16
如果不使用@ManagedBean注释的name属性,则必须引用第一个字母转换为小写的bean。
从@ManagedBean javadoc
名称()属性的值被认为是
-bean-name。如果名称属性的值未指定或为空字符串,则通过获取完全限定类名的非限定类名部分并将第一个字符转换为小写来派生托管bean名称。例如,如果ManagedBean注释位于一个完全限定类名为com.foo.Bean的类上,并且注释上没有name属性,那么managed- bean -name将被视为bean。该批注所附加到的类的完全限定类名被认为是managed-bean- class。
发布于 2011-10-29 02:47:57
由于您使用的是jsf2
您可以执行以下操作-为bean命名...
@ManagedBean(name="Profile")
@SessionScoped
public class Profile implements Serializable{
}https://stackoverflow.com/questions/7873498
复制相似问题