Service与controller实现取出完整信息

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38087648/article/details/80007725

CustomRealm

CustomRealm用于实现Controller逻辑

CustomRealm注入service
@Autowired
//静态模拟数据库读取数据
User user = new User();
user.setUserid();
........
//根据用户id取出数据
List<user> userList = userServiceImpl.get.....();
//将userList设置到simpleAuthenticationInfo中
SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(userList, password,this.getName());
Controller主页显示
//从shiro的session中去userList
Subject subject = SecurityUtils.getSubject();
//取身份信息
User user = (user)subject.getPrincipal();
//通过model传到页面
model.addAttribute("",);
return "main";

猜你喜欢

转载自blog.csdn.net/qq_38087648/article/details/80007725
今日推荐