简体   繁体   中英

In Struts1.3, From Jsp page to action in Java

I am new to Jsp, and My working application is based on Struts1.3 . I have a Jsp page which display the records basis on the providedId, may be record should be one or more than one it depends on the existence of records. My Jsp page code is:

<html:form method="post" action="properties.do" styleId="propertyform">
  <logic:iterate id="JobsForm" name="<%=Constant.JOBFORMLISTSECOND%>">
    <tr>
      <td>
        <html:text property="asfrom" name="JobsForm" styleClass="fieldbox2" styleId="textfield50"/>
      </td>

      <td>
        <html:select property="withauthority" name="JobsForm">
          <html:option value="0">Select</html:option>
          <html:options collection="<%=Constant.INSTALLEDBY%>" property="value" labelProperty="label"/>
        </html:select>
      </td>
    </tr>
  </logic:iterate>

  <table>
    <tr>
      <td>
        <img onclick="submitPropertyForm(),update()" src="images/new.jpg" />
      </td>
    </tr>
  </table>
</html:form>

And, What i need, after clicking on the button I need all the values of given properties but I am unable to do this, I got only one value of all properties in my action my action is like.

JobsForm jobsForm = (JobsForm) form;
System.out.println("asFrom:::" + jobsForm.getAsfrom());
System.out.println("withAuth:::" + jobsForm.getWithauthority());  

Can you guide me how to do this.Or What i have to do? for getting all the values of all properties.

Many Thanks,

You want indexed properties .

Basically, you need to provide names like asfrom[n] where n is your loop index.

Struts does provide indexed tags , although the documentation lists some reasons you might just want to use JSTL. That just depends on your needs.

On a side note, please take care when formatting your code, both for your benefit, and that of others. Proper indentation and whitespace usage make structure and intent far easier to communicate, and it's one way to tell if someone cares about their code. I also removed some JSP not necessary to describe the problem.

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