html: 文本标签不起作用

发布于 2024-07-29 18:07:06 字数 4808 浏览 1 评论 0原文

我有一个看起来有点像这样的表单:

public class MaintainForecastInputForm extends ActionForm {
  private MainMenuForm mainMenuForm = new MainMenuForm();
  public SelectProdLineAssociationForm selectProdLineAssociationForm = new SelectProdLineAssociationForm();
  private EconometricDataForm econometricDataForm = new EconometricDataForm();
    private EconometricImportDownloadForm econometricImportDownloadForm = new EconometricImportDownloadForm();
    private String userAction;
    private List<MaintainForecastInputForm.DemandForecast> demands = new ArrayList<MaintainForecastInputForm.DemandForecast>();
    private List<MaintainForecastInputForm.DemandForecast> forecasts = new ArrayList<MaintainForecastInputForm.DemandForecast>();
    private DemandForecast iimsForecast = new DemandForecast();
    private DemandForecast econometricForecast = new DemandForecast();

  public static class DemandForecast {
        private String subType;
        private String shortTermWtAvg="0.0";
        private String midTermWtAvg="0.0";
        private String longTermWtAvg="0.0";
        private String shortTermPct="0.0";
        private String midTermPct="0.0";
        private String longTermPct="0.0";
        private List yearDemands = new ArrayList();

    public static class Year { 
            private String fyTotalValue="0.0";
            private String fyPctChange="0.0";
      private List monthDemands = new ArrayList();

      public String getFyPctChange() {
                return fyPctChange;
            }

            public void setFyPctChange(String fyPctChange) {
                this.fyPctChange = fyPctChange;
            }

            public String getFyTotalValue() {
                return fyTotalValue;
            }

            public void setFyTotalValue(String fyTotalValue) {
                this.fyTotalValue = fyTotalValue;
            }
    } // Year

      public static class Month {
            private String demandValue="0.0";
            private String demandQuantity="0.0";

      public String getDemandQuantity() {
                return demandQuantity;
            }

            public void setDemandQuantity(String demandQuantity) {
                this.demandQuantity = demandQuantity;
            }

            public String getDemandValue() {
                return demandValue;
            }

            public void setDemandValue(String demandValue) {
                this.demandValue = demandValue;
            }
    } // Month

    public String getLongTermPct() {
            return longTermPct;
        }

        public void setLongTermPct(String longTermPct) {
            this.longTermPct = longTermPct;
        }

        public String getLongTermWtAvg() {
            return longTermWtAvg;
        }

        public void setLongTermWtAvg(String longTermWtAvg) {
            this.longTermWtAvg = longTermWtAvg;
        }

        public String getMidTermPct() {
            return midTermPct;
        }

        public void setMidTermPct(String midTermPct) {
            this.midTermPct = midTermPct;
        }

        public String getMidTermWtAvg() {
            return midTermWtAvg;
        }

        public void setMidTermWtAvg(String midTermWtAvg) {
            this.midTermWtAvg = midTermWtAvg;
        }

        public String getShortTermPct() {
            return shortTermPct;
        }

        public void setShortTermPct(String shortTermPct) {
            this.shortTermPct = shortTermPct;
        }

        public String getShortTermWtAvg() {
            return shortTermWtAvg;
        }

        public void setShortTermWtAvg(String shortTermWtAvg) {
            this.shortTermWtAvg = shortTermWtAvg;
        }

        public String getSubType() {
            return subType;
        }

        public void setSubType(String subType) {
            this.subType = subType;
        }

        public List getYearDemands() {
            return yearDemands;
        }

        public void setYearDemands(List yearDemands) {
            this.yearDemands = yearDemands;
        }
    } // DemandForecast
}

在我的 JSP 中,我有以下内容:

<c:forEach items="${form.iimsForecast.yearDemands}" var="yearDemand"             varStatus="year">
  <tr>
    <td>${yearDemand.fiscalYear}</td>
    <c:forEach items="${yearDemand.monthDemands}" var="yearMonth"                   varStatus="month">
      <c:choose>
        <c:when test="${year.count == 1 && month.count < yearDemand.currentMonth}">
          <td class="lightShaded dmnd">
            <html-el:text property="form.iimsForecast.yearDemands.monthDemands.demandValue">
          </td>
...

我收到 JSP 异常 - 在表单中找不到 getter 属性,尽管它存在。 有人可以帮我解决这个问题吗?

I have a form that looks somewhat like this:

public class MaintainForecastInputForm extends ActionForm {
  private MainMenuForm mainMenuForm = new MainMenuForm();
  public SelectProdLineAssociationForm selectProdLineAssociationForm = new SelectProdLineAssociationForm();
  private EconometricDataForm econometricDataForm = new EconometricDataForm();
    private EconometricImportDownloadForm econometricImportDownloadForm = new EconometricImportDownloadForm();
    private String userAction;
    private List<MaintainForecastInputForm.DemandForecast> demands = new ArrayList<MaintainForecastInputForm.DemandForecast>();
    private List<MaintainForecastInputForm.DemandForecast> forecasts = new ArrayList<MaintainForecastInputForm.DemandForecast>();
    private DemandForecast iimsForecast = new DemandForecast();
    private DemandForecast econometricForecast = new DemandForecast();

  public static class DemandForecast {
        private String subType;
        private String shortTermWtAvg="0.0";
        private String midTermWtAvg="0.0";
        private String longTermWtAvg="0.0";
        private String shortTermPct="0.0";
        private String midTermPct="0.0";
        private String longTermPct="0.0";
        private List yearDemands = new ArrayList();

    public static class Year { 
            private String fyTotalValue="0.0";
            private String fyPctChange="0.0";
      private List monthDemands = new ArrayList();

      public String getFyPctChange() {
                return fyPctChange;
            }

            public void setFyPctChange(String fyPctChange) {
                this.fyPctChange = fyPctChange;
            }

            public String getFyTotalValue() {
                return fyTotalValue;
            }

            public void setFyTotalValue(String fyTotalValue) {
                this.fyTotalValue = fyTotalValue;
            }
    } // Year

      public static class Month {
            private String demandValue="0.0";
            private String demandQuantity="0.0";

      public String getDemandQuantity() {
                return demandQuantity;
            }

            public void setDemandQuantity(String demandQuantity) {
                this.demandQuantity = demandQuantity;
            }

            public String getDemandValue() {
                return demandValue;
            }

            public void setDemandValue(String demandValue) {
                this.demandValue = demandValue;
            }
    } // Month

    public String getLongTermPct() {
            return longTermPct;
        }

        public void setLongTermPct(String longTermPct) {
            this.longTermPct = longTermPct;
        }

        public String getLongTermWtAvg() {
            return longTermWtAvg;
        }

        public void setLongTermWtAvg(String longTermWtAvg) {
            this.longTermWtAvg = longTermWtAvg;
        }

        public String getMidTermPct() {
            return midTermPct;
        }

        public void setMidTermPct(String midTermPct) {
            this.midTermPct = midTermPct;
        }

        public String getMidTermWtAvg() {
            return midTermWtAvg;
        }

        public void setMidTermWtAvg(String midTermWtAvg) {
            this.midTermWtAvg = midTermWtAvg;
        }

        public String getShortTermPct() {
            return shortTermPct;
        }

        public void setShortTermPct(String shortTermPct) {
            this.shortTermPct = shortTermPct;
        }

        public String getShortTermWtAvg() {
            return shortTermWtAvg;
        }

        public void setShortTermWtAvg(String shortTermWtAvg) {
            this.shortTermWtAvg = shortTermWtAvg;
        }

        public String getSubType() {
            return subType;
        }

        public void setSubType(String subType) {
            this.subType = subType;
        }

        public List getYearDemands() {
            return yearDemands;
        }

        public void setYearDemands(List yearDemands) {
            this.yearDemands = yearDemands;
        }
    } // DemandForecast
}

and in my JSP I have the following:

<c:forEach items="${form.iimsForecast.yearDemands}" var="yearDemand"             varStatus="year">
  <tr>
    <td>${yearDemand.fiscalYear}</td>
    <c:forEach items="${yearDemand.monthDemands}" var="yearMonth"                   varStatus="month">
      <c:choose>
        <c:when test="${year.count == 1 && month.count < yearDemand.currentMonth}">
          <td class="lightShaded dmnd">
            <html-el:text property="form.iimsForecast.yearDemands.monthDemands.demandValue">
          </td>
...

I'm getting a JSP exception - getter property is not been found in the form although it is there. Can somebody help me with this problem please?

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

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

发布评论

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

评论(2

情归归情 2024-08-05 18:07:06

您的代码不会显示表单上是否有 getIimsForecast() 方法(它只显示 iimsForecast 属性) - 如果没有,则需要添加它。 然而,这并不是唯一的问题。

您的属性路径包括 yearDemandsmonthDemands 以及两个返回 List 的 getter 方法。 这是非法的 - 嵌套属性路径必须具有单个 bean 或具有列表元素的索引访问权限(例如 iimsForecast.yearDemands[0].monthDemands[0].demandValue)。

最后,您可能不需要在属性路径前添加 form 前缀,尽管这取决于您的配置以及是否有封闭的 标记。

Your code does not show whether you have a getIimsForecast() method on your form (it only shows iimsForecast property) - if you don't, you need to add it. However, that's not the only problem.

Your property path includes yearDemands and monthDemands and getter methods for both return Lists. That's illegal - nested property path must either have single beans or have indexed access for list elements (e.g. iimsForecast.yearDemands[0].monthDemands[0].demandValue).

Finally, you probably don't need to prefix your property path with form, although that depends on your configuration and whether you have an enclosing <html:form> tag.

十年九夏 2024-08-05 18:07:06

这听起来似乎很明显,但是您是否将标签库添加到页面中?

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html-el" %>

This may sound obvious, but did you add the tag library to the page?

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html-el" %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文