Visualforce 默认选中顶点:选择Visual force页面中的选项

Visualforce 默认选中顶点:选择Visual force页面中的选项,visualforce,apex,Visualforce,Apex,在HTML中,我们可以选择默认选中单选按钮。下面的HTML代码片段也显示了同样的内容 男性 女性 我已经找到了解决方案,并在下面提供了相同的解决方案 Visualforce页面: <apex: page controller="SampleCustomController"> <apex:selectRadio value="{!defaultCheck}"> <apex:selectOptions value="Male" name="

在HTML中,我们可以选择默认选中单选按钮。下面的HTML代码片段也显示了同样的内容


男性
女性

我已经找到了解决方案,并在下面提供了相同的解决方案

Visualforce页面:

<apex: page controller="SampleCustomController">
<apex:selectRadio value="{!defaultCheck}">
            <apex:selectOptions value="Male" name="Male"/>
            <apex:selectOptions value="Female" name="Female"/>
</apex:selectRadio>
</apex:page>
public class SampleCustomController{
public String defaultCheck{get;set;}

SampleCustomController(){

if(defaultCheck==NULL)
{   defaultCheck='Male';}

}
}