私はSpring SecurityをSpringブートアプリケーションで使用していますが、現在ログインしているユーザーをPrincipal#getName
から取得したいのですが、テンプレート解決のエラーがあり、 。現在のログインしているユーザーをspring + angularにする
これは私のコントローラである:
import java.security.Principal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class PageController {
@RequestMapping(value = "/api/loggeduser", method = RequestMethod.GET)
public String printWelcome(ModelMap model, Principal principal) {
String name = null;
if (principal !=null) {
name = principal.getName();
}
model.addAttribute("username", name);
return name;
}
}
そして、これは私のAngularJsがログインしているユーザーを取得する機能である:
app.controller('Usercontr', function($scope, $http) {
$http.get("/api/loggeduser").success(function (data) {
$scope.nom = data;
console.log($scope.nom)
})
});
そして、ここではエラーです:
Error resolving template "kamel.mili", template might not exist or might not be accessible by any of the configured Template Resolvers
Kamel.mili
ですログインしたユーザー名手伝ってくれませんか。私はログインページにthymeleafを使用していますが、その他のものはすべてHTML + AngularJsです。私はなぜthymeleafがこのコントローラーに手を携えていたのか分かりません。
それは私が問題retreivingデータを持っていることが解析できないようです –