How Do I Return A String From The Spring Mvc Controller Without A View Javapedia Net
What Is Spring Mvc Model View Controller Explained With spring 4, if your controller is annotated with @restcontroller instead of @controller, you don't need the @responsebody annotation. the code would be. @requestmapping(value=" controller", method=get) public string foo() { return "response!"; you can find the javadoc for @restcontroller here. However, if you want your controller to return a simple string response (for example, as a restful api), you can do this by using the `@restcontroller` annotation. this allows your controller to write directly to the http response body without needing a view to render the result.
Github Gedeongg Java Code Spring Mvc Controller Modelandview Controller 1. set the http response code 2. return a string back, don't need to render a .jsp view page or anything.

Java Spring Mvc Controller Not Returning Correct View Stack Overflow
Comments are closed.