日期:2014-05-16  浏览次数:20345 次

在jsp页面跳转后保持radio的值

jsp获取radio的值

悬赏分:0 - 解决时间:2009-5-24 19:05
我现在在jsp中这样一个radio:
<input type="radio" name="keyMan" value=""/>是
<input type="radio" name="keyMan" value=""/>否
我在后台返回一个“是”,请问我怎么在页面上显示选择在是上? 
提问者: kkkkkoioi - 三级
最佳答案
首先你的代码是有问题的,你选“是”还是“否”的标准时你的value值,然而你的value值现在都是空字符串。你这样写

在后台不要返回是,返回数字1或者0赋值给变量i。
<%int i = request.getParameter("value");%>
<input type="radio" name="keyMan" value="1" <%if(i==1){out.print("select");} %>/>是 
<input type="radio" name="keyMan" value="0" <%if(i==1){out.print("select");} %>/>否 
这样你就可以动态的控制radio的默认选择了。