Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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 hateoas中子对象的暴露字段_Spring_Spring Rest_Spring Hateoas - Fatal编程技术网

Spring hateoas中子对象的暴露字段

Spring hateoas中子对象的暴露字段,spring,spring-rest,spring-hateoas,Spring,Spring Rest,Spring Hateoas,我定义了两个实体: @Entity public class VideoPost { private @Id @GeneratedValue(strategy= GenerationType.IDENTITY) Long id; private String videoTitle; private @ManyToOne @JoinColumn(name = "VideoPost_Id") User uploader; private boolean isP

我定义了两个实体:

@Entity
public class VideoPost {
    private @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY) Long id;
    private String videoTitle;
    private @ManyToOne @JoinColumn(name = "VideoPost_Id") User uploader;
    private boolean isPublished = false;

    //....
}


@Entity
public class User {
    private @Id @GeneratedValue(strategy=GenerationType.IDENTITY) Long id;
    private String userName;
    private Date registrationDate;

    @OneToMany(mappedBy = "uploader", cascade = CascadeType.ALL)  private List<VideoPost> videoPosts;

    //...

}
我想直接公开这个响应中的上传程序名称。即

"uploader" : {
    "userName": theName
    "href" : "http://localhost:8080/api/videoPosts/1/uploader"
}

如何实现这一点?

您可以检查在何处可以按您想要的方式自定义对象,无论是显示整个嵌套属性还是部分嵌套属性,甚至隐藏这些嵌套对象

您可以检查在何处可以按您想要的方式自定义对象,无论是显示整个嵌套属性还是部分嵌套属性或者甚至隐藏这些嵌套对象

您是使用spring data rest提供HTTP端点,还是编写了自己的控制器并使用
org.springframework.hateoas.Resource
呈现资源?是使用spring data rest提供HTTP端点,还是编写了自己的控制器并使用
org.springframework.hateoas.Resource
呈现资源?
"uploader" : {
    "userName": theName
    "href" : "http://localhost:8080/api/videoPosts/1/uploader"
}