小技巧:ADF獲得URL參數的方法


小技巧:在管理Bean中獲得當前視圖(JSP頁面)URL中提交的參數的方法。


這種方式適用於無邊界任務流和右邊界任務流,在進入任務流頁面的時候提交,注意頁面相互跳轉期間參數會丟失,所以建議將管理Bean的生命週期設定爲頁面流(PageFlow),在管理Bean的構造方法中進行參數獲取。。

例如:abc.jspx?name=test

    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = ((HttpServletRequest)
    context.getExternalContext().getRequest());
    String name = request.getParameter("name");
    if (name == null) {
        name = "def";
    }
    System.out.println("URL name="+name);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章