If statement 单选按钮的Grails If-else条件
我有3个单选按钮,选中后将运行不同的查询。 我不知道if-else条件如何适用于grails单选按钮,因为我对grails完全陌生。。 这是我的普惠制页面If statement 单选按钮的Grails If-else条件,if-statement,radio-button,grails-2.0,If Statement,Radio Button,Grails 2.0,我有3个单选按钮,选中后将运行不同的查询。 我不知道if-else条件如何适用于grails单选按钮,因为我对grails完全陌生。。 这是我的普惠制页面 <label>Search id:</label><input type = "text" name = "searchid1"> <input type ="submit" name ="search" value ="Go!"> <br> <g:radio name="
<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"/>
您用于GSP的方法是正确的。但是,在控制器中,您需要添加IF-ELSE语句
if (request.getParameter("myGroup").equals("input1"))
{
println("duck")
redirect (action: radio)
}
if (request.getParameter("myGroup").equals("input2"))
{
println("chicken")
redirect (action: abc)
}
在控制器中添加if-else条件,您的问题将得到解决。您用于GSP的方法是正确的。但是,在控制器中,您需要添加IF-ELSE语句
if (request.getParameter("myGroup").equals("input1"))
{
println("duck")
redirect (action: radio)
}
if (request.getParameter("myGroup").equals("input2"))
{
println("chicken")
redirect (action: abc)
}
在控制器中添加if-else条件,问题将得到解决