I have a simple controller class exposing two rest endpoints.
Removing the @ResponseBody is giving different behavior for the two endpoints.
If removed from testRest method - output is =
"1..name"
"1..name..name"
"1..name..name..name"
and so on, finally Stackoverflow exception is thrown
If removed from testSimple method - No Exception , output is "Test simple", response to Postman is :-
{
"timestamp": "2020-06-09T17:20:02.511+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/testSimple"
}
Code is :-
package com.search.catalog.rest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class TestController {
@RequestMapping(value="/test/{id}", method = RequestMethod.GET)
@ResponseBody
public String testRest(@PathVariable String id, @RequestParam String name) {
System.out.println(id + ".." + name);
return "result is " + id+ ".." + name;
}
@RequestMapping(value="/testSimple", method = RequestMethod.GET)
@ResponseBody
public String testSimple() {
System.out.println("Test Simple ");
return "Test Simple ";
}
}