jeecgboot后端java及前端vue无参数获取当前登录用户名等信息

后端在controller中,注意,必须为带请求的接口,定时任务无法获得此信息。

LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = loginUser.getId();
String username = loginUser.getUsername();

前端pc端默认获取方法

import store from '@/store'
 
...
this.userInfo = store.getters.userInfo
this.username = store.getters.userInfo.username
this.userId = store.getters.userInfo.id

你可能感兴趣的:(javaweb,jeecg,jeecgboot)