呵呵,那鬱悶的問題解決了

Map params = ActionContext.getContext().getParameters();
原來params是以數組的形式存參數值的,修改後的程序段爲:
    public Object getModel() {
        if(userDTO != null) return userDTO;
        Integer pid = null; 
        String sid = null;
        Map params = ActionContext.getContext().getParameters();
        if(params.get("id")!=null)
        {         
            sid = ((String[])params.get("id"))[0];
        }
        if(sid!=null&&!sid.equals("")) {
            try {
                user = userService.getUserByID(new Integer(sid));
                //po 轉換成 dto
                userDTO = new UserDTO(user);
            } catch (Exception e) {
                log.error("該用戶已不存在",e);
            }
        }else{
            userDTO = new UserDTO();
        }
        return userDTO;
    }
發佈了38 篇原創文章 · 獲贊 0 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章