Home  >  Forum  >  Spring
Post New Query

what is the controller return type in spring?

joined on
December 08,2013
Asked on December 08,2013
any body please send to me please this is my mail id
joined on
March 14,2013
Replied on December 08,2013

In Spring MVC, the below return types are possible.

1. ModelAndView 
2. Model 
3. Map 
4. View 
5. String
6. void
7.  Callable<?> : if application wants return asynchronously in thread managed MVC
8. When method is annotated with @ResponseBody, the return type is written directly to the response HTTP body.

@RequestMapping(value = "/somepattern", method = RequestMethod.PUT)
public String doTask()  {
  return "Hello World";

9. Set values in response header using HttpEntity as given below

  HttpHeaders responseHeaders = new HttpHeaders();
  responseHeaders.set("SomeResponseHeader", "some Value");
  return new ResponseEntity<String>("Some Message", responseHeaders, HttpStatus.CREATED);

10.  DeferredResult<?> 

Find the link below  for more detail from spring Doc

Write Answer

Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us