hibernate - unable to pass two lits to the jsp using apachi tiles -
i using spring mvc apache tile , hibernate.i pass tow lists jsp page.but print there's no thing prints.
my controller class follows :
if(userexists!=0){ model.addattribute("maintabs",new maintab()); model.addattribute("maintabslist",loginservice.listmaintabs()); model.addattribute("subtabs",new subtab()); model.addattribute("subtabslist",loginservice.listsubtab(userexists)); return "redirect:/loginsucess"; }else{ model.addattribute("error", "error : invaliduser !,please try again!"); return "loginform"; }
jsp page follows (menu.jsp):
<c:if test="${not empty subtabslist}"> <c:foreach var="ob" items="${subtabslist}"> <c:out value="200"/> <%-- <c:out value="${ob.maintab}"/> --%> <%-- <c:out value="${ob.description}"/> --%> <%-- <c:out value="${ob.ref}"/> --%> </c:foreach> </c:if>
i want populate dynamic menu.please me in jsp code.
subtab modelclass :
package net.abc.form; // default package // generated jun 7, 2015 11:03:29 hibernate tools 4.0.0 import java.util.hashset; import java.util.set; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.generatedvalue; import static javax.persistence.generationtype.identity; import javax.persistence.id; import javax.persistence.joincolumn; import javax.persistence.manytoone; import javax.persistence.onetomany; import javax.persistence.table; /** * subtab generated hbm2java */ @entity @table(name = "subtab", catalog = "abc") public class subtab implements java.io.serializable { private integer subtabid; private maintab maintab; private string description; private string ref; private set<authintication> authintications = new hashset<authintication>(0); public subtab() { } public subtab(maintab maintab, string ref) { this.maintab = maintab; this.ref = ref; } public subtab(maintab maintab, string description, string ref, set<authintication> authintications) { this.maintab = maintab; this.description = description; this.ref = ref; this.authintications = authintications; } @id @generatedvalue(strategy = identity) @column(name = "subtabid", unique = true, nullable = false) public integer getsubtabid() { return this.subtabid; } public void setsubtabid(integer subtabid) { this.subtabid = subtabid; } @manytoone(fetch = fetchtype.lazy) @joincolumn(name = "maintabid", nullable = false) public maintab getmaintab() { return this.maintab; } public void setmaintab(maintab maintab) { this.maintab = maintab; } @column(name = "description", length = 45) public string getdescription() { return this.description; } public void setdescription(string description) { this.description = description; } @column(name = "ref", nullable = false, length = 45) public string getref() { return this.ref; } public void setref(string ref) { this.ref = ref; } @onetomany(fetch = fetchtype.lazy, mappedby = "subtab") public set<authintication> getauthintications() { return this.authintications; } public void setauthintications(set<authintication> authintications) { this.authintications = authintications; } }
you're adding attributes , sending redirect. lose informations set. if redirect page show right. example:
if(userexists!=0){ model.addattribute("maintabs",new maintab()); model.addattribute("maintabslist",loginservice.listmaintabs()); model.addattribute("subtabs",new subtab()); model.addattribute("subtabslist",loginservice.listsubtab(userexists)); return "successpage"; }else{ model.addattribute("error", "error : invaliduser !,please try again!"); return "loginform"; }
if wanna redirect data, can use httpsession.
session.setattribute("maintabs",new maintab());
Comments
Post a Comment