Select box struts 2 example
Select box in struts2 is stateful mean now we can get default selected box with defining in select tag. Select box use with list option where can define value and id of the option.
Example will show you how to use select box in struts2
<s:select headerKey="0" headerValue="Select Month" name="smonth" list="#{'1':'Jan','2':'Feb','3':'Mar','4':'Apr','5':'May','6':'Jun'}" value="5" />

- 1. headerKey will set header default value
- 2. headerValue will set header default option
- 3. list will set options with value and text
- 4. value is attribute set default selected value of option in select box, if we set 5 value it will automatically selected May month option
Tags: struts2



Link to Us
Hello friend,
I have one question suppose if i select month or year in the box then if i submit then it should display the month or year respectively plz ans to this