Sorry but I am new in Playframwork
wanted download the data from Db as json file. I am able to convert DB data and display on browser but not able to download as json file.
public Result userListToJson() {
List<User> userList = User.find.all();
return ok(Json.toJson(userList))
}
You need to add Content-Disposition
header, so your code will be
public Result userListToJson() {
List<User> userList = User.find.all();
return ok(Json.toJson(userList)).withHeaders("Content-Disposition" -> "attachment; filename=users.json")
}
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.