How to get json data from spring boot's @RequestMapping and @ResponseBody

Answered

hi ,
    We have used spring boot and webdatarocks  in our project .when we set the conf  as following:

var pivot = new WebDataRocks({
        container: “#wdr-component”,
        toolbar: true,
        height: height,
        report: {
            dataSource: {
                filename:  ‘initPivotTableJsonFromDb?objectID’+objectID // (not a json file extension,but a spring boot controller method)
            }
        }

and the component returns :
Unable to open file “initPivotTableJsonFromDb?objectID=”+objectID&436826254.

It seems that this file doesn’t exist or ‘Access-Control-Allow-Origin’ header is absent in the resource requested.
 
Is the url must be json file extension suffix?
Thanks
 
Huntley
 

2 answers

WebDataRocks Team WebDataRocks November 1, 2019

Hello, Huntley,
 
Thank you for the question.
 
We recommend checking your browser’s console to make sure that WebDataRocks uses the correct URL as an endpoint.
 
The reason for the described mistake can also appear because you are trying to access the resources from a different domain. The majority of browsers follow CORS security policies to prevent cross-domain requests.
We recommend placing the data on your own server with configured CORS: https://enable-cors.org/.
 
Kind regards,
WebDataRocks Team

huntley November 2, 2019

Hello,WebDataRocks Team

    We have checked the spring boot url and corrected it as your recommed and works fine now.
Kind regards
Huntley

Please login or Register to Submit Answer