我有 3 个单选按钮,当它们被选中时,会运行不同的查询。我不知道 if-else 条件如何适用于 grails 单选按钮,因为我对 grails 完全陌生。这是我的 gsp 页面。
<label>Search id:</label><input type = "text" name = "searchid1">
<input type ="submit" name ="search" value ="Go!">
<br>
<g:radio name="myGroup" value="input1"/>
<g:radio name="myGroup" value="input2"/>
<g:radio name="myGroup" value="input3"/>
以及控制器站点上的查询..
String searchQ1 = "select * from alert_list where id = " + params.searchid1
def searchit1 = sql.rows(searchQ1)
String searchQ2 = "select * from Admin where id = " + params.searchid1
def searchit2 = sql.rows(searchQ2)
String searchQ3 = "select * from sec_user where id = " + params.searchid1
def searchit3 = sql.rows(searchQ3)
[searchit1: searchit1, searchit2: searchit2, searchit3: searchit3]