I am coming to an issue where I am getting three objects instead of one object itself. (You can see my schema and the output result I am getting below). All I need to do is return a list of the Object Mapper that can transforms the collection in an array. In my controller this is the cause "public @ResponseBody List" please help me to have it print like my schema. Thank you for the help..!
Controller:
@RestController
public class AutoCompleteController {
private AutoCompleteService autoCompleteService;
private EntityManager em;
public AutoCompleteController(AutoCompleteService autoCompleteService, EntityManager em){
this.autoCompleteService = autoCompleteService;
this.em = em;
}
@RequestMapping(value = "jobs", method = RequestMethod.GET)
public @ResponseBody List<AutoComplete> getSalary(@RequestParam(value = "autocomplete") String autocompleteValue) {
return autoCompleteService.retrieveSalary(autocompleteValue);
}
public void getAllSalaries(HttpServletResponse res) {
Stream<AutoComplete> stream = autoCompleteService.retrieveAllSalaries();
DataStreamUtility.streamObjects(stream, res, em);
}
@RequestMapping(value = "/jobs")
public @ResponseBody List < AutoComplete > getSalary(@RequestParam(value = "autocomplete", defaultValue = "1400") String autocompleteValue) {
return autoCompleteService.retrieveSalary(autocompleteValue);
}
public void getAllSalaries(HttpServletResponse res) {
Stream < AutoComplete > stream = autoCompleteService.retrieveAllSalaries();
DataStreamUtility.streamObjects(stream, res, em);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…