2011-08-02 303 views
0

试图抓住<spring:bind>标签。我正在尝试打印一个字符串值。代码看起来是这样的:
春季MVC春季:绑定标签

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

从哪里获得从另一个豆 “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"> 

回答

0

您可以使用,而不是绑定标签消费满输入标签

<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} 
+0

Thanks Objects .. Will tr​​y this :) – t0mcat