您好我有一个代码,我希望将我的Collection公开为JSON格式。我以为Spring会自动完成它。这是代码:
@RestController
public class BirthdayController extends BaseController{
@RequestMapping("/api/v1/birthday")
public TreeMap<Integer, TreeMap<Integer, ArrayList<BirthdayDetails>>> getBirthdays(@RequestParam(value="startYear") Integer startYear,
@RequestParam(value="startMonth") Integer startMonth,
@RequestParam(value="endYear") Integer endMonth,
@RequestParam(value="endMonth") Integer endYear) {
BirthdayServiceImpl birthdayService = new BirthdayServiceImpl();
return birthdayService.getBirthdaysBetweenDate(startMonth, startYear, endMonth, endYear);
}
}
我在访问端点时只获得空{}
答案 0 :(得分:2)
试,
@RequestMapping("/api/v1/birthday")
public @ResponseBody TreeMap<Integer, TreeMap<Integer, ArrayList<BirthdayDetails>>> getBirthdays(@RequestParam(value="startYear") Integer startYear,
@RequestParam(value="startMonth") Integer startMonth,
@RequestParam(value="endYear") Integer endMonth,
@RequestParam(value="endMonth") Integer endYear) {
BirthdayServiceImpl birthdayService = new BirthdayServiceImpl();
return birthdayService.getBirthdaysBetweenDate(startMonth, startYear, endMonth, endYear);
}