简体   繁体   中英

Spring 2.6.3 how to return id in response

Im making a api with spring, in which I return an array of objects, each of them contains name and an array. The problem is that it doesn't return the Id of each object which I store in jpa repository. The question is how do I turn Id visible in response

@Column
private @Id @GeneratedValue Long id;
private String QuestionName;

Good evening,

However, I am going to assume your code snippet is from a class using the @ Entity<\/code> annotation.

By using a function with a return format of ResponseEntity<\/code> , you can return HTTP messages to the client. In this return statement, you may return whatever you please, meaning you may return a JSON back to the client in question.

为 id 字段添加 getter 和 setter 方法,然后尝试。

"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM