【发布时间】:2018-02-17 16:01:12
【问题描述】:
我正在测试 Spring Data REST。 我关注了this tutorial 以了解它是如何工作的。
到目前为止的代码很简单:
@Entity
@SequenceGenerator(name="my_seq", sequenceName="user_id_seq")
@Table(name = "employees")
data class Employee (@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "my_seq") val id: Long? = null,
val name: String = "defConstructorHell")
当我用 GET 询问时,我得到以下 json:
{
"_embedded" : {
"employees" : [ {
"name" : "ciao",
"_links" : {
"self" : {
"href" : "http://localhost:5000/api/employees/1"
},
"employee" : {
"href" : "http://localhost:5000/api/employees/1"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:5000/api/employees{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://localhost:5000/api/profile/employees"
}
},
"page" : {
"size" : 20,
"totalElements" : 1,
"totalPages" : 1,
"number" : 0
}
}
这完全没问题,但我使用的 js 框架需要标头 X-Total-Count。
您知道是否有使用 Spring Data REST 的方法吗?
【问题讨论】:
-
你看到这个帖子stackoverflow.com/q/19251846/5380322了吗?...
标签: spring rest spring-data-rest