我认为这是一个小问题。我想修改p:menuButton的attibute值,我想从我的用户bean中获取值(在我的应用程序中记录之后),例如取用户名(getName)。
我确实喜欢:
<p:menuButton value="#{user.getName}">
<p:menuitem value="My profile" action="#{toolbarView.edit}" update="" icon="ui-icon-disk" />
<p:menuitem value="log out" actionListener="#{toolbarView.close}" update="" icon="ui-icon-arrowrefresh-1-w" />
</p:menuButton>
但是我在界面图中遇到了这个问题(当我进入我的localhost时):
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: /profile.xhtml @55,53 value="#{user.getName}": Property 'getName' not found on type com.live.beans.User
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause
javax.el.PropertyNotFoundException: /profile.xhtml @55,53 value="#{user.getName}": Property 'getName' not found on type com.live.beans.User
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
org.primefaces.component.menubutton.MenuButton.getValue(MenuButton.java:96)
org.primefaces.component.menubutton.MenuButtonRenderer.encodeButton(MenuButtonRenderer.java:64)
org.primefaces.component.menubutton.MenuButtonRenderer.encodeMarkup(MenuButtonRenderer.java:53)
org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:113)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:88)
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:71)
org.primefaces.component.column.renderer.PanelGridBodyColumnRenderer.encode(PanelGridBodyColumnRenderer.java:41)
org.primefaces.component.column.ColumnRenderer.encodeEnd(ColumnRenderer.java:50)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:88)
org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:71)
org.primefaces.component.row.renderer.PanelGridBodyRowRenderer.encode(PanelGridBodyRowRenderer.java:33)
org.primefaces.component.row.RowRenderer.encodeEnd(RowRenderer.java:50)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
org.primefaces.component.panelgrid.PanelGridRenderer.encodeStaticBody(PanelGridRenderer.java:155)
org.primefaces.component.panelgrid.PanelGridRenderer.encodeTableBody(PanelGridRenderer.java:104)
org.primefaces.component.panelgrid.PanelGridRenderer.encodeTableLayout(PanelGridRenderer.java:65)
org.primefaces.component.panelgrid.PanelGridRenderer.encodeEnd(PanelGridRenderer.java:37)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
我的bean用户喜欢:
@ManagedBean(name="user")
public class User {
private int id;
private String name;
@Column(unique=true)
private String email;
private String password;
private String confirmationPass;
public User() {
super();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getConfirmationPass() {
return confirmationPass;
}
public void setConfirmationPass(String confirmationPass) {
this.confirmationPass = confirmationPass;
}
public User(int id, String name, String email, String password,
String confirmationPass) {
super();
this.id = id;
this.name = name;
this.email = email;
this.password = password;
this.confirmationPass = confirmationPass;
}
public User(int id, String name, String email, String password) {
super();
this.id = id;
this.name = name;
this.email = email;
this.password = password;
}
public User(String name, String email, String password) {
super();
this.name = name;
this.email = email;
this.password = password;
}
@Override
public String toString() {
return "User [id=" + id + ", Name=" + name + ", email=" + email
+ ", password=" + password + "]";
}
}
此外,当我使用user.name
代替user.getName
时,我的界面图片上没有任何内容,就像我value=" "
一样,它在界面图形中没有显示任何内容。
<p:menuButton value="#{user.name}">
<p:menuitem value="My profile" action="#{toolbarView.edit}" update="" icon="ui-icon-disk" />
<p:menuitem value="log out" actionListener="#{toolbarView.close}" update="" icon="ui-icon-arrowrefresh-1-w" />
</p:menuButton>
感谢能帮助我的人
答案 0 :(得分:-2)
好的,将您的属性(值=&#34;#{user.getName}&#34;&gt;)名称从getName更改为name,然后在&#34; user&#34;中更改assingh回豆特产&#34;名称&#34;用它的吸气剂和吸气剂。