Reputation: 621
While running tests against this controller, I get the Circular View Path error. Replacing @Controller
with @RestController
fixes this error however now instead of the view showing in the browser I get the actual returned String
in the view.
Example would be, when I replace @Controller
below with @RestController
and make a GET
request mapping to "/ListA"
, the controller method returns the String ListA
in the browser as in all you see printed in the browser are the letters ListA and the view with all my inputs, buttons, tables do not show.
What am I missing here?
@RestController
@RequestMapping
public class WebController {
@GetMapping("/ListA")
public String viewListAController() {
return "ListA";
}
@GetMapping("/ListB")
public String viewListBController() {
return "ListB";
}
}
Upvotes: 0
Views: 287
Reputation: 91
@RestController simplifies the creation of RESTful web services. It's a convenience annotation that combines @Controller and @ResponseBody.
if you use it it will convert the response into a JSON object format. That's why you are getting a string as text in the browser, not the view.
Upvotes: 1