简体   繁体   中英

Unable to fetch data from database

See a code below:

<label>Subject:</label>
<s:select onchange = "form1.submit();" 
             theme = "simple" 
              list = "#{'':'All','E':'English','M':'Maths','S':'Science','H':'Humanities'}" 
              name = "Subject" 
                id = "Subject"  />

But when I change drop-down to E(English) when page loads, drop-down changes to 'ALL' and data is also not showing.

When you change drop-down to E(English) the change event happens and you have used onchange event handler which submits the form to the server. The server returns the page back to the client but it doesn't know the value it should set because it's not set. You should either change the event handler to not submit the form at least with the ordinal request or use ajax to send the data, or create getters and setters for the named field to hold the value of the key in the list. Also you can't use empty keys as values of the list, because it doesn't match the selected key. You can also use a value attribute of the s:select tag to pre-select the value from the list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM