好的,我知道在上面的示例中Spring已经在解析Principal对象,因此我的参数解析器没有启动。我很懒,并将@CurrentUser批注添加到现有参数中。
所以我改变了我的榜样
@RequestMapping(method = RequestMethod.POST, value = "/update")public ModelAndView update(@RequestParam MultipartFile background, @CurrentUser Principal principal) { ...}使用我的用户模型类
@RequestMapping(method = RequestMethod.POST, value = "/update")public ModelAndView update(@RequestParam MultipartFile background, @CurrentUser User user) { ...}现在就可以了!



