Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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
Spring Hibernate与JSP问题_Spring_Hibernate_Jsp_Sorting - Fatal编程技术网

Spring Hibernate与JSP问题

Spring Hibernate与JSP问题,spring,hibernate,jsp,sorting,Spring,Hibernate,Jsp,Sorting,我有两个实体具有OneToMany关系。另外,我还有一个jsp,其中我使用DAO获取一些相关值,DAO返回一个带有一个键的列表 例如: 大学 学生甲,学生乙 我不需要在DAO中编写其他方法来获得相关的学生。大学里只有一种方法,我可以从学生那里得到所有的价值观,因为OneToMany关系。没关系。但我想对学生进行分类。这就是问题所在。大学实体没有学生专栏。 我怎样才能解决这个问题?我可以在mysql中对我的表(学生)进行排序,并从已经排序的数据库中获取它吗? 这是我的jsp: <c:forE

我有两个实体具有
OneToMany
关系。另外,我还有一个jsp,其中我使用DAO获取一些相关值,DAO返回一个带有一个键的列表

例如:

大学

学生甲,学生乙

我不需要在DAO中编写其他方法来获得相关的学生。大学里只有一种方法,我可以从学生那里得到所有的价值观,因为
OneToMany
关系。没关系。但我想对学生进行分类。这就是问题所在。大学实体没有学生专栏。 我怎样才能解决这个问题?我可以在mysql中对我的表(学生)进行排序,并从已经排序的数据库中获取它吗? 这是我的jsp:

<c:forEach items="${spyList}" var="spy">
        <c:forEach items="${spy.spyPath}" var="spyPath">
            <table style="width: 800px; border-collapse: collapse;" width=""
                align="">
                <tbody>
                    <tr>

                        <td
                            style="width: 450px; letter-spacing: 0px; word-spacing: 0px; vertical-align: top;"><strong>

                                <strong> <a
                                    href="${pageContext.request.contextPath}${spyPath.url}">${spyPath.title}</a>
                            </strong>
                        </strong><br></td>
                        <td style="width: 20px; letter-spacing: 0px; word-spacing: 0px;"><br></td>
                        <td
                            style="vertical-align: top; letter-spacing: 0px; word-spacing: 0px;"><div
                                id='date'>
                                <small>${spyPath.time}</small>
                            </div> <br></td>
                    </tr>
                </tbody>
            </table>
        </c:forEach>
    </c:forEach>
public List getSpyPath()
这将返回要排序和显示的列表。因此,在JSP中显示之前,使用比较器对其进行排序


Java教程解释了如何对集合进行排序。

我将在客户端使用datatables对JSP/HTML表进行排序。您是否询问如何对
列表进行排序?读不到,我还没有名单。我有一个单键列表。我不能分类,因为它没有理由。我如何对一个值进行排序?你说:“但我想对学生进行排序。这就是问题所在。”。那么,如果问题不在于对学生名单进行排序,那么实际的麻烦是什么呢?您想要实现什么?
public List getSpyPath()
:这将返回您想要排序和显示的列表,不是吗?因此,在JSP中显示之前对其进行排序<代码>绑定不匹配:类型集合的泛型方法排序(列表)不适用于参数(列表)。推断的类型SpyPath不是有界参数
Collections.sort(SpyPath,new SpyPath())的有效替代品@OneToMany(mappedBy = "spy")
    private List<SpyPath> spyPath = new ArrayList<SpyPath>();

    public List<SpyPath> getSpyPath() {
        return this.spyPath;
    }

    public void setSpyPath(List<SpyPath> spyPath) {
        this.spyPath = spyPath;
    }
@ManyToOne
    @JoinColumn(name = "ID")
    private Spy spy;

    public Spy getSpy() {
        return this.spy;
    }

    public void setSpy(Spy spy) {
        this.spy = spy;
    }
public List<SpyPath> getSpyPath()