2011-08-02 301 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