java - Referring path variable in jsp Spring framework -



java - Referring path variable in jsp Spring framework -

i pass couple of objects "studentdetails" , string-"dept" jsp.

question-

how refer studentdetail.st.fname in jsp file? ie; need refer firstname pupil object.

i tried , failing -

<form:label path="s.studentdetail.st.fname" class="labels">first name</form:label> , <form:label path="studentdetail.st.fname" class="labels">first name</form:label> @requestmapping(value = "/student", method = requestmethod.get) public modelandview student() { map<string, object> model = new hashmap<string, object>(); model.put("studentdetail", new studentdetails()); model.put("department", "dept"); homecoming new modelandview("student", "s", model); }

studentdetails:

public class studentdetails { public contactinfo getci() { homecoming ci; } public void setci(contactinfo ci) { this.ci = ci; } public pupil getst() { homecoming st; } public void setst(student st) { this.st = st; } contactinfo ci; pupil st; }

student:

public class pupil { private integer age; private string fname; private string mname; private string lname; private string dob; private string gender; private string birthplace; private string nationality; private string mothertongue; private string religion; private integer id; public integer getage() { homecoming age; } public void setage(integer age) { this.age = age; } public string getfname() { homecoming fname; } public void setfname(string fname) { this.fname = fname; } public string getmname() { homecoming mname; } public void setmname(string mname) { this.mname = mname; } public string getlname() { homecoming lname; } public void setlname(string lname) { this.lname = lname; } public string getdob() { homecoming dob; } public void setdob(string dob) { this.dob = dob; } public string getgender() { homecoming gender; } public void setgender(string gender) { this.gender = gender; } public string getbirthplace() { homecoming birthplace; } public void setbirthplace(string birthplace) { this.birthplace = birthplace; } public string getnationality() { homecoming nationality; } public void setnationality(string nationality) { this.nationality = nationality; } public string getmothertongue() { homecoming mothertongue; } public void setmothertongue(string mothertongue) { this.mothertongue = mothertongue; } public string getreligion() { homecoming religion; } public void setreligion(string religion) { this.religion = religion; } public integer getid() { homecoming id; } public void setid(integer id) { this.id = id; } }

contactinfo

public class contactinfo { string addr1; string addr2; string city; string state; string pin; string country; string phone; string mobile; string email; public string getaddr1() { homecoming addr1; } public void setaddr1(string addr1) { this.addr1 = addr1; } public string getaddr2() { homecoming addr2; } public void setaddr2(string addr2) { this.addr2 = addr2; } public string getcity() { homecoming city; } public void setcity(string city) { this.city = city; } public string getstate() { homecoming state; } public void setstate(string state) { this.state = state; } public string getpin() { homecoming pin; } public void setpin(string pin) { this.pin = pin; } public string getcountry() { homecoming country; } public void setcountry(string country) { this.country = country; } public string getphone() { homecoming phone; } public void setphone(string phone) { this.phone = phone; } public string getmobile() { homecoming mobile; } public void setmobile(string mobile) { this.mobile = mobile; } public string getemail() { homecoming email; } public void setemail(string email) { this.email = email; } }

working code:---

<h2>student information</h2> <form:form method="post" action="/springmvc/addstudent" modelattribute="studentdetail"> <br><br> <form:label path="st.fname" class="labels">first name</form:label> <form:input path="st.fname" class="textbox" /> <br><br> studentdetail:${studentdetail.st.fname} <br> department:${department} <br><br> </form>

controller:-

@requestmapping(value = "/student", method = requestmethod.get) public modelandview student() { map<string, object> model = new hashmap<string, object>(); model.put("studentdetail", new studentdetails()); model.put("department", "dept"); homecoming new modelandview("student",model);

try :

<form:label path="s['studentdetail'].st.fname" class="labels">first name</form:label>

java spring jsp

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -