0

I have a controller method which should return some data. I'm wondering why despite it's GET and marked with @ResponseBody it's void.

@ResponseBody    
@RequestMapping(value = "/{id}/data", method = GET)
public void getData(....) { // < Question: how it can be void?
  ....
  dataService.streamData(query); // < this method is also void
}

Question: What spring returns in this case? Is this method useless?

VB_
  • 45,112
  • 42
  • 145
  • 293

1 Answers1

2

If a controller returns a null view name, or declares a void return type, Spring will attempt to infer the view name from the request URL.

It does this using an implementation of RequestToViewNameTranslator, the default implementation of which is DefaultRequestToViewNameTranslator

complete info here

Community
  • 1
  • 1
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116