【问题标题】:Spring MVC spring:bind tagSpring MVC spring:bind 标签
【发布时间】:2011-08-02 18:04:07
【问题描述】:

试图获取<spring:bind> 标签。我正在尝试打印一个字符串值。代码如下所示:

  mySimpleBean myBean = presentStudent.getSubjects().getTeacherName();
    String firstName = myBean.getTeacherFirstName() 

我从另一个 bean“presentStudent”中获得“myBean”。在 jsp 上我正在尝试:

  <spring:bind path="presentStudent.subjects.teacherName.teacherFirstName">
    <input type="text" name="${status.expression}" value="${status.value}">

但它不打印任何东西。 “presentStudent”也是这种形式的 commandObject:

<form:form id="stuTeachForm" name="stuTeachForm" method="post" commandName="presentStudent"
    action="getStuTeachData.html">

【问题讨论】:

    标签: spring jsp spring-mvc jstl jsp-tags


    【解决方案1】:

    你可以使用sping输入标签代替绑定标签

    <form:form id="stuTeachForm" name="stuTeachForm" method="post" commandName="presentStudent" action="getStuTeachData.html">
       <form:input type="text" path="subjects.teacherName.teacherFirstName"/>
    

    也可能值得输出所需的值以检查您的 bean 是否已正确填充

    First name is ${presentStudent.subjects.teacherName.teacherFirstName}
    

    【讨论】:

    • 感谢 Objects.. 会试试这个:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-01
    • 2023-04-01
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2018-02-04
    • 2015-10-16
    相关资源
    最近更新 更多