0

I am using Bootstrap Table Extentions in a asp:

<table id="tbl" data-toggle="table" data-height="299" data-url="${data}" data-toolbar="#filter-bar" data-show-toggle="true" data-show-columns="true" data-show-filter="true">

I have a json string java object in a Spring @RestFullcontroller:

@RequestMapping(value = "/getTableData")
public String getTableData() {
    List<Product> products = productDao.getAll();
    GsonBuilder gsonBuilder = new GsonBuilder();
    Gson gson = gsonBuilder.registerTypeAdapter(Product.class, new   ProductAdapter()).create();
    String p = gson.toJson(products);
    System.out.println(p);
    return p;
}

Setting the data-url with ${data} does not work. Any ideas? Can I put /getTableData for the url?

1 Answer 1

0

I believe data-url="" attribute suppose url that return data as json, you just trying to put json as string to that attribute.

Two ways:

1) Take a look on your table and try find out something like data attribute, that receive data as array and pass data as you do now

2) Change your servlet/controller code to return json that will be accessible by url, you just need set response content type as "application/json" and write your data to response output. Here is an example Returning JSON response from Servlet to Javascript/JSP page

Sign up to request clarification or add additional context in comments.

4 Comments

How to I make the url request the data?
Ok, try to put your full url to attribute, data-url="/getTableData", make sure your url return json, put your url in browser and you should see json string
Still no luck i have localhost:8080/mypath/getTableData
When I go there there is json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.