Struts2 the value of the input box in the form after the JSP form is submitted drop-down box select and input

Source: Internet
Author: User

Original address: Struts2 JSP form submits the value in the input box in the form drop-down box select and input

JSP page
1 function Dosearch () {
2 if ($ ("#textValue"). val () = = "") {
3 $ ("#errortip"). HTML ("<font color= ' #FF0000 ' > Please enter query content </font>");
4 return false;
5}
6 $ (' #searchform '). Submit ();
7}

1 <form id= "searchform" name= "Searchform" action= "listpsinfo.action" method= "POST" >
2 <div id= "sr" class= "B1 MB10" >
3 <ul id= "SR_BQ" >
4 <li class= "on" >
5 <div>
6 Find Employee Information
7 </div>
8 </li>
9 </ul>
Ten <select class= "Sa_w_tx" style= "width:100px" id= "SelectType" name= "Psinfodo.name" >
One <option value= "1" <s:if test= "Optionvalue==1" >selected= "selected" </s:if>> Work No. </opt Ion>
<option value= "2" <s:if test= "optionvalue==2" >selected= "selected" </s:if>> (nickname) < /option>
<option value= "3" <s:if test= "optionvalue==3" >selected= "selected" </s:if>> real name </o Ption>
<option value= "4" <s:if test= "optionvalue==4" >selected= "selected" </s:if>> mailbox </opt Ion>
</select>
<input type= "text" class= "Sa_w_tx" style= "width:180px;" id= "TextValue" name= "Psinfodo.value" value= "&lt ; S:property value= "Psinfodo.value"/> "maxlength=" title= "Please enter the appropriate content does not allow null value"/>&nbsp;&nbsp;
<input type= "button" value= "Query" class= "BTN1" id= "subform" onclick= "Dosearch ();" />&nbsp;&nbsp; <div id= "Errortip" ></div>
</form>
To preserve the value in the drop-down list box, save the value in option with a variable optionvalue when the form is submitted to the action so that the optionvalue is returned to the
The JSP uses the STRUTS2 label S:if as a judge to use the value of the drop-down box to retain the
1 <option value= "1" <s:if test= "Optionvalue==1" >selected= "selected" </s:if>> Work No. </option>

The normal input input box can use the domain model in the action.

Action
1 private Ipeoplesoftinfobo Peoplesoftinfobo;
2 private Peoplesoftinfodo Psinfodo;
3 Private Peoplesoftinfodo Querypsinfo;
4 private String OptionValue;

1 public String Listpsinfo () throws Exception {
2
3 This.optionvalue=psinfodo.getname ();
4 this.querypsinfo=peoplesoftinfobo.findpsinfobyconditions (Psinfodo);
5
6 if (querypsinfo==null)
7 {
8 Addfielderror ("Userlognamemessage", "the system does not exist this employee information, please check and manually set the operator's basic information");
9}
Ten return SUCCESS;
11}

Struts2 the value of the input box in the form after the JSP form is submitted drop-down box select and input

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.