假设我有一个单选框在前台,
- HTML code
<s:form name="targetForm" action="login"> <s:textfield name="username" label="用户名"></s:textfield> <s:password name="password" label="密 码"></s:password> <s:radio label="用户类型" name ="type" list= "{'学生','管理员'}"/> <s:submit value="登陆" /> </s:form>
那么的话,我这个单选框
- HTML code
<s:radio label="用户类型" name ="type" list= "{'学生','管理员','游客'}"/>
里面的值有三个,我在后台的action里面获取不到单选框的值吗?
例如我这么做:
- Java code
public class LoginAction extends BaseAction{ private String type; …………………… //省略无关变量的setter public String getType() { return type; } public void setType(String type) { this.type = type; }
然后就会报错:
严重: Servlet.service() for servlet jsp threw exception
tag 'radio', field 'list', name 'type': The requested list key '{'学生','管理员''}' could not be resolved as a collection/array/map/enumeration/iterator type[color=#FF0000][/color]. Example: people or people.{name} - [unknown location]
1,难道不是用String类存放单选框的值吗?
2,如何设置让单选框的默认选中 管理员那个选项呢?
------解决方案--------------------------------------------------------