我有Spring MVC的REST通道:如何在Spring MVC REST通道中獲取登錄的用戶名/主體?
@Controller
@RequestMapping("/rest")
public class REST {
,我有我的方法:
@RequestMapping(value = "/doSomething")
public @ResponseBody DoSomethingResultDTO doSomething(
@RequestBody DoSomethingRequestDTO)
現在我需要在登錄的用戶名一般情況下,我可以通過該方法做
HttpServletRequest.getUserPrincipal()
但如何在這裏?我有標題註釋(@RequestHeader
),甚至cookie(@CookieValue
)。但是我怎麼能在我的方法中獲得Principal
?
OK,我的錯誤是,我只用註釋嘗試過。 –