Html 预先选择一个<;s:收音机>;Struts2中的按钮

Html 预先选择一个<;s:收音机>;Struts2中的按钮,html,jsp,struts2,Html,Jsp,Struts2,这是我的单选按钮代码 <s:radio name="filter" requiredposition="right" list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'STOP'}" value = "STATUS_FILTER_START"></s:radio> 或 但什么都不管用。 有人能帮我吗? 我不想要html:radio标记。在动作类中设置默认值,并在OGNL中使用该值来告诉选择哪

这是我的单选按钮代码

<s:radio name="filter" requiredposition="right"
list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'STOP'}" 
 value = "STATUS_FILTER_START"></s:radio>


但什么都不管用。
有人能帮我吗?
我不想要html:radio标记。

在动作类中设置默认值,并在OGNL中使用该值来告诉选择哪个值作为默认值

List<String> filter= new ArrayList<String>();
        filter.add("START");
        filter.add("STOP");


    public List<String> getFilter() {
        return filter;
    }
    public String getDefaultFilterValue(){
        return "STOP";
    }
List filter=new ArrayList();
过滤器。添加(“开始”);
过滤。添加(“停止”);
公共列表getFilter(){
回流过滤器;
}
公共字符串getDefaultFilterValue(){
返回“停止”;
}
在jsp中使用

<s:radio label="filter" name="filter" list="filter" value="defaultGenderValue" />


我使用了simple ArrayList,但您可以自由使用Map。

在action类中设置默认值,并在OGNL中使用该值告诉您选择哪个值作为默认值

List<String> filter= new ArrayList<String>();
        filter.add("START");
        filter.add("STOP");


    public List<String> getFilter() {
        return filter;
    }
    public String getDefaultFilterValue(){
        return "STOP";
    }
List filter=new ArrayList();
过滤器。添加(“开始”);
过滤。添加(“停止”);
公共列表getFilter(){
回流过滤器;
}
公共字符串getDefaultFilterValue(){
返回“停止”;
}
在jsp中使用

<s:radio label="filter" name="filter" list="filter" value="defaultGenderValue" />


我使用了简单的ArrayList,但您可以自由使用Map。

也适用于使用静态值的开发人员。以下是解决方案:

<s:radio label="correctOption" name="correctAnswer" list=" 
#{'1':'1','2':'2','3':'3','4':'4'}" value="1"/>

对于静态列表中的字符串,另一种情况是:

<s:radio label="Gender" name="gender" list=" 
    #{'male':'Male','female':'Female'}" value="'male'"/>

也适用于使用静态值的开发人员。以下是解决方案:

<s:radio label="correctOption" name="correctAnswer" list=" 
#{'1':'1','2':'2','3':'3','4':'4'}" value="1"/>

对于静态列表中的字符串,另一种情况是:

<s:radio label="Gender" name="gender" list=" 
    #{'male':'Male','female':'Female'}" value="'male'"/>


只需在action类中设置值,并在
value
参数中使用该值。@umeshawashi-Hi-Umesh不工作,我将初始化过滤器设置为“START”,但它仍然没有被预选。只需在action类中设置值,并在
value
参数中使用该值。@umeshawashi-Hi-Umesh不工作,我已将筛选器初始化为“开始”,但它仍然不是预选的Hanks umesh u always help me:)谢谢umesh u always help me:)