开发者

Spring MVC spring:bind tag

开发者 https://www.devze.com 2023-03-24 12:06 出处:网络
Trying to get hold of <spring:bind> tag. I am trying to print a String value. The code looks somet开发者_StackOverflow中文版hing like:

Trying to get hold of <spring:bind> tag. I am trying to print a String value. The code looks somet开发者_StackOverflow中文版hing like:

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

Where I get "myBean" from another bean "presentStudent". On jsp I am trying:

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

But it doesnt print anything. Also "presentStudent" is commandObject for this form:

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


You can use the sping input tag instead of the bind tag

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

Might also be worth outputting the desired value to check your bean has been properly populated

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

精彩评论

暂无评论...
验证码 换一张
取 消