我遇到了一个问题,我得到了三个对象而不是一个对象本身。(您可以在下面看到我的架构和输出结果)。我需要做的就是返回一个对象映射器列表,它可以将集合转换为数组。在我的控制器中,这是“public @ResponseBody List”的原因,请帮助我让它像我的模式一样打印。感谢您的帮助..!
控制器:
@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);
}
}
呼啦一阵风
蓝山帝景
慕少森
相关分类