I am using Spring MVC 3.2.2
I have defined a custom HandlerMethodArgumentResolver class like this
public class CurrentUserArgumentResolver implements
OK I worked out that Spring was already resolving the Principal object in my above example and so my argument resolver was not kicking in. I had been lazy and added the @CurrentUser annotation to an existing parameter.
So I changed my example
@RequestMapping(method = RequestMethod.POST, value = "/update")
public ModelAndView update(@RequestParam MultipartFile background, @CurrentUser Principal principal) {
...
}
to use my User model class
@RequestMapping(method = RequestMethod.POST, value = "/update")
public ModelAndView update(@RequestParam MultipartFile background, @CurrentUser User user) {
...
}
and now it works!