Http://www.itzhai.com/struts2-radio-button-label-s-radio-use-and-set-the-default-value.html
First, the Struts tag library is introduced in the page:
<%@ taglib prefix= "s" uri= "/struts-tags"%>
To create a radio button radio in a JSP page:
<s:radio list= "#{' 1 ': ' Mr. ', ' 0 ': ' Lady '}" name= "Gender" value= "1"/>
Where the key-value pairs in list represent all options, value represents the default value of the setting, and if this default is passed from the background, you can set it up:
<s:radio list= "#{' 1 ': ' Mr. ', ' 0 ': ' Lady '}" name= "Gender" value= "#{buyer_gender}"/>
Note that this is using the # symbol instead of $.
FUNI16: I wrote <s:radio list= "#{1: ' Recommended to peripheral personal module ', 0: ' Not recommended '}" Name= "Recommendenable" value= "recommendenable" ></s: Radio> Because the property I need is an integer type, so it doesn't have to be written in the form of a string, and I'm getting it is also an integer type, and recommendenable is the data I've got in the background, so write the value directly.
If the value is not obtained from the background, written as <s:radio list= "#{1: ' Recommended to peripheral personal module ', 0: ' Not recommended '} ' Name=" recommendenable "value=" 1 "></s:radio> You can default to 1. method to get the value of S:radio
S:radio is also very easy to obtain, if the action in Struts2 is directly using the label's Name property to obtain:
First declare a property named Radio name, and then add getter and Setter methods:
String gender;
Public String Getgender () {
return gender;
}
public void Setgender (String gender) {
this.gender = gender;
}
This allows you to get the selected value directly. (Select a value for the label of the list property of the key value pair, as in the above 1 or 0)