Help us understand the problem. What is going on with this article?

メモ

More than 3 years have passed since last update.

ajax

index.js
$("#init").on('click', function(){
    $.ajax({
           type: "GET",
            url: "/init",
      dataType : "json"
    }).then(
        function(data){
            $("#foodList").empty();

            for (var i = 0; i < data.length; i++) {
                $("#foodList").append(
                    "<tr>"
                     +"<td> <a class='btn btn-default' href='/actor/detail?id='" +data[i].id+ "'>" + data[i].name + "</a></td>"
                     +"<td class='item-price'>" + data[i].price + "</td>"
                     +"<td class='item-category'>" + data[i].classification + "</td>"
                     +"<td>" + data[i].vendor + "</td>"
                     +"<td>"
                     +"<form action='/delete/' method='post'>"
                     +"<input class='btn btn-warning' type='submit' value='delete'>"
                     +"</form>"
                     +"</td>"
                     +"</tr>"
                );
            }
        }
    )
});

FoodController.java
    public Result init() {
        FoodService service = new FoodService();
        return ok(Json.toJson(service.findByIdLimitNum()));
    }
routes
GET       /init                       controllers.FoodController.init

getのパラメータ取得

Controller.java
  String id = request().getQueryString("id");
bergamot
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away