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

被刻印的时光 ゝ 提交于 2019-12-25 02:14:20

问题


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,


回答1:


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.



来源:https://stackoverflow.com/questions/7927998/in-struts1-3-from-jsp-page-to-action-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!