Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 无法使用apachi tiles将两个LIT传递给jsp_Hibernate_Jsp_Spring Mvc_Tiles - Fatal编程技术网

Hibernate 无法使用apachi tiles将两个LIT传递给jsp

Hibernate 无法使用apachi tiles将两个LIT传递给jsp,hibernate,jsp,spring-mvc,tiles,Hibernate,Jsp,Spring Mvc,Tiles,我将SpringMVC与ApacheTile和hibernate一起使用。我将两个列表传递到jsp页面。但是它是通过打印的,但是没有任何东西可以打印 我的控制器类如下所示: if(userExists!=0){ model.addAttribute("Maintabs",new Maintab()); model.addAttribute("MaintabsList",loginService.listMaintabs());

我将SpringMVC与ApacheTile和hibernate一起使用。我将两个列表传递到jsp页面。但是它是通过打印的,但是没有任何东西可以打印

我的控制器类如下所示:

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页面如下(menu.jsp):


我想填充动态菜单。请帮助我输入jsp代码

子选项卡模型类:

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;
    }

}
package net.ABC.form;
//默认包
//Hibernate Tools 4.0.0于2015年6月7日上午11:03:29生成
导入java.util.HashSet;
导入java.util.Set;
导入javax.persistence.Column;
导入javax.persistence.Entity;
导入javax.persistence.FetchType;
导入javax.persistence.GeneratedValue;
导入静态javax.persistence.GenerationType.IDENTITY;
导入javax.persistence.Id;
导入javax.persistence.JoinColumn;
导入javax.persistence.manytone;
导入javax.persistence.OneToMany;
导入javax.persistence.Table;
/**
*hbm2java生成的子选项卡
*/
@实体
@表(name=“subtab”,catalog=“ABC”)
公共类子选项卡实现java.io.Serializable{
私有整数子表;
专用主选项卡主选项卡;
私有字符串描述;
私有字符串引用;
私有集验证=新哈希集(0);
公共子选项卡(){
}
公共子选项卡(Maintab Maintab,String ref){
this.maintab=maintab;
this.ref=ref;
}
公共子选项卡(Maintab Maintab,字符串描述,字符串引用,
设置身份验证){
this.maintab=maintab;
this.description=描述;
this.ref=ref;
this.authintications=授权;
}
@身份证
@生成值(策略=标识)
@列(name=“SubtabId”,unique=true,nullable=false)
公共整数getSubtabId(){
返回此.subtabId;
}
public void setSubtabId(整数子选项卡){
this.subtabId=subtabId;
}
@manytone(fetch=FetchType.LAZY)
@JoinColumn(name=“MainTabId”,nullable=false)
公共Maintab getMaintab(){
返回此.main选项卡;
}
公共void setMaintab(Maintab Maintab){
this.maintab=maintab;
}
@列(name=“description”,长度=45)
公共字符串getDescription(){
返回此.description;
}
公共void集合描述(字符串描述){
this.description=描述;
}
@列(name=“ref”,null=false,长度=45)
公共字符串getRef(){
返回此.ref;
}
公共void setRef(字符串ref){
this.ref=ref;
}
@OneToMany(fetch=FetchType.LAZY,mappedBy=“subtab”)
公共集GetAuthentications(){
返回此文件。验证;
}
公共无效设置身份验证(设置身份验证){
this.authintications=授权;
}
}

您正在添加属性并发送重定向。它将丢失您设置的所有信息。如果您重定向到该页面,它将正确显示。例如:

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";
    }
如果要对数据进行重定向,可以使用HttpSession

session.setAttribute("Maintabs",new Maintab());

我无法通过ob.maintab访问名为unkonwn“maintab”的错误。如果我引用为[p>${ob}

,则打印为[Ljava.lang.Object;@1f43d69如何获取实际值。域类具有mintab属性。thaks作为您的答案!您的列表可能不是返回子选项卡列表,而是对象列表…因为如果您调用
${ob maintab}

,并且您的maintab属性有getter,它应该正确打印。当您调用

${ob}

时,它打印“java.lang.Object…”,但它应该打印“your.package.Subtabs”,我返回subtab objec public List listSubtab(int usertype){List subtablist=(List)sessionFactory.getCurrentSession().createQuery(“从子选项卡s中选择s.maintab、s.description、s.ref,其中s.Subtab=a.Subtab和a.usertype='“+usertype+””)。list();return subtablist;}maintab是否有getter方法?子选项卡是hibernate模型类。
session.setAttribute("Maintabs",new Maintab());