i am using spring mvc with Apache tile and hibernate.i pass tow lists to the jsp page.but it is print by but there's no any thing prints.
my controller class as 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 as 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 to populate dynamic menu.please help me in jsp code.
subtab modelclass :
package net.ABC.form;
// default package
// Generated Jun 7, 2015 11:03:29 AM by 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 by 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 the attributes and sending redirect. It will lose all the informations that you set. If you redirect to the page it will show it right. Example:
If you wanna do a redirect with the data, you can use HttpSession.