I am using spring mvc with freetemplate.
In asp.net, you can write straight to the browser using Response.Write(\"hello, world\");
Can you do this in spring
You can either:
get the HttpServletResponse
and print to its Writer
or OutputStream
(depending on whether you want to send textual or binary data)
@RequestMapping(value = "/something")
public void helloWorld(HttpServletResponse response) {
response.getWriter().println("Hello World")
}
Use @ResponseBody:
@RequestMapping(value = "/something")
@ResponseBody
public String helloWorld() {
return "Hello World";
}
Thus your Hello World
text will be written to the response stream.