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 mvc?
You can either:
get the HttpServletResponse and print to its Writer or OutputStream (depending on whether you want to send textual or binary data)
HttpServletResponse
Writer
OutputStream
@RequestMapping(value = "/something") public void helloWorld(HttpServletResponse response) { response.getWriter().println("Hello World") }
Use @ResponseBody:
@ResponseBody
@RequestMapping(value = "/something") @ResponseBody public String helloWorld() { return "Hello World"; }
Thus your Hello World text will be written to the response stream.
Hello World
1.4m articles
1.4m replys
5 comments
56.9k users