如何使成功消息显示出来?我有以下代码,但只出现警告消息。我必须进行哪些更改才能在我的成功页面中显示成功消息?
用户bean.java:
public String Login() throws Exception {
String status = "failure";
current=userBo.validateUser(getLogin(),getPass());
if(current!=null){ exist=false; status = "success";
String message = "submitted successfully !!";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message)); }
exist=true; return status; }
登录.xhtml:
<f:view>
<h:form>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th>Username</th>
<td><h:inputText value="#{user.login}"
styleClass="login-inp" /></td>
</tr>
<tr>
<th>Password</th>
<td><h:inputSecret value="#{user.pass}"
onfocus="this.value=''" styleClass="login-inp" /></td>
</tr>
<tr>
<th></th>
<!-- <td><input type="button" class="submit-login" /> -->
<td><h:commandButton action="#{user.checkUser}" styleClass="submit-login" />
<h:messages globalOnly="true" />
</td>
</tr>
</table>
</h:form>
</f:view>
成功.xhtml:
<h:form>
<h:body>
<h1>heyyyy ,y sucseded !!!</h1> <br/><br/>
<h:commandLink action ="#{user.logout}" > disconnect </h:commandLink>
</h:body>
</h:form>
警告信息 :
Infos: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(INFO 0), summary=(submitted successfully !!), detail=(submitted successfully !!)]