Spring Securityを使ってSpring MVCのWebアプリを作ろうと思っています。
現在ログインしているユーザのユーザ名を知りたいのですが、以下のようなやり方で合っているでしょうか?
lang
1@RequestMapping(method = RequestMethod.GET) 2public ModelAndView showResults(final HttpServletRequest request...) { 3final String usr = SecurityContextHolder.getContext().getAuthentication().getName(); 4}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。