I have a spring boot project with 2 controller files as below:
File1.java
@GetMapping(value = "/test")
public List<Object> getdata() {
String e_url = ""; //external API with above JSON data
RestTemplate rt = new RestTemplate();
Object[] test = rt.getForObject(e_url,Object[].class);
return Arrays.asList(test);
}
File2.java
public class controller2 extends HttpServlet {
Public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException {}
Public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException
Public static void pr(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
//From here I want to display the JSON data to web interface which passes from controller 1
}
}
When I run it throws this error
HTTP Status 500 – Internal Server Error
and shows an error on the
Object[] test = rt.getForObject(e_url,Object[].class);
line .
I want to show JSON Data on the web interface through another controller and connect 1st and 2nd controller through the POST method
The JSON format is:
{
"seconds": 0.00163,
"records": [
{
"id": "cc:1001",
"column": "col:10",
"idn": "tester.",
"topic": "W",
"rnk": 2,
"tid": "txn:218",
"stp": "M"
}
]
}
Could you please give some suggestions on how I could accomplish this?