2013-07-31 63 views
0

基本上我使用下面的代碼進行調試。它呈現爲空,我不知道 的原因。順便說一下,else語句總是會在這一點上執行。起初我 沒有保存方法,但我認爲它可能會解決我的問題。可能與 有關係我的域名範圍?截至目前我已經將它們設置爲會話範圍: 類信息{ 靜態範圍= 「會話」 字符串名稱 字符串smokingStatus 的String []症狀 靜態約束= { } }Grails參數傳遞


 else{//query did not find patient with that id 
      def patInfo = new Info() 
      patInfo.name = "Dennis" 
      patInfo.smokingStatus = "Former Smoker" 
      patInfo.symptom = ["Cough"] 
      patInfo.save() 
      redirect(action:"display", params: [patInfo:patInfo]) 
      //redirect(action:"login") 
      //return to login action and 
     } 
    } 
} 

def display(){ 
    render params.name 
} 

非常感謝您的任何幫助。

+0

你能發表一些周圍的上下文代碼嗎?這並不是那麼有價值。 –

+0

嗨丹尼斯,你告訴我們「else」語句總是執行,但是我們沒有看到條件語句。我們如何弄清楚? –

回答

1

您是分配patInfo的變量名patInfo值,以便在顯示動作必須使用:

render params.patInfo 

例如,如果您將使用以下命令:

redirect(action:"display", params: [duck:patInfo]) 

必須使用:

render params.duck