用户进入http://localhost:8080/test/active.jsp?username=xxx&activecode=yyy页面active.jsp
  <h:inputText id="username" value="#{accountActiveBean.username}" required="true" maxlength="30"/>
  <h:inputText id="activecode" value="#{accountActiveBean.activecode}" required="true" maxlength="30"/>
  <h:inputSecret id="password" value="#{accountRegisterBean.password}" required="true" maxlength="20"/>如何让username和activecode得到url中的参数"xxx","yyy"?

解决方案 »

  1.   

    在你的bean中用如下的方法获得:
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("username").toString();
    你可在accountActiveBean中的get方法中用以上的方法:
    如下面的写法:
    public String getUsername(){
          if(null!=this.username){
         return this.username;
    }else return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("username").toString();
    }