I want to display on my jsp something like this
CategoryParent1
-----Subcategory1
-----Subcategory2
CategoryParent2
-----Subcategory1
-----Subcategory2
In which way i can solve it? Does spring-mvc has some library for it? Or i must use some external libraries?
I have a Category model
@Entity
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
@ManyToOne
private Category parentCategory;
@OneToMany(mappedBy = "parentCategory", cascade = CascadeType.ALL)
private List<Category> childCategories = new ArrayList<>();
public Category() {
}
public Category(String name){
this.name = name;
}
public Category(String name, Category parentCategory) {
this.name = name;
this.parentCategory = parentCategory;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Category getParentCategory() {
return parentCategory;
}
public void setParentCategory(Category parentCategory) {
this.parentCategory = parentCategory;
}
public List<Category> getChildCategories() {
return childCategories;
}
public void setChildCategories(List<Category> childCategories) {
this.childCategories = childCategories;
}
}