package com.pinyougou.manager.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
@RequestMapping("/login")
public class LoginController { @RequestMapping("name") public Map name(){
String name=SecurityContextHolder.getContext()
.getAuthentication().getName(); Map map=new HashMap();
map.put("loginName", name);
}
}
//登陆服务层app.service('loginService',function($http){
//读取登录人名称
this.loginName=function(){
return $http.get('../login/name.do');
}
});
app.controller('indexController' ,function($scope,$controller ,loginService){
//读取当前登录人
$scope.showLoginName=function(){ loginService.loginName().success(
function(response){
$scope.loginName=response.loginName;
}
);
}
});
<script type="text/javascript" src="../plugins/angularjs/angular.min.js"></script>
<script type="text/javascript" src="../js/base.js"></script>
<script type="text/javascript" src="../js/service/loginService.js"></script>
<script type="text/javascript" src="../js/controller/indexController.js"></script>
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |