Struts1.3中,从Jsp页面到Java中的action

发布于 2024-12-12 09:27:18 字数 1346 浏览 2 评论 0原文

我是 Jsp 新手,我的工作应用程序基于 Struts1.3。我有一个Jsp页面,它根据提供的Id显示记录,可能记录应该是一条或多条,这取决于记录的存在。 我的 Jsp 页面代码是:

<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>

而且,我需要什么,单击按钮后,我需要给定属性的所有值,但我无法做到这一点,我在我的操作中只获得了所有属性的一个值,我的操作是这样的。

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

你能指导我如何做到这一点吗?或者我必须做什么?用于获取所有属性的所有值。

非常感谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2024-12-19 09:27:19

您需要索引属性

基本上,您需要提供诸如 asfrom[n] 之类的名称,其中 n 是循环索引。

Struts 确实提供索引标签,尽管文档列出了您可能只想使用 JSTL 的一些原因。这仅取决于您的需求。

附带说明一下,在格式化代码时请务必小心,这既是为了您也是为了他人的利益。正确的缩进和空格使用使结构和意图更容易沟通,这是判断某人是否关心他们的代码的一种方法。我还删除了一些不需要描述问题的JSP。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文