数据库
ssm
bean层,dao层:
service层:
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userDao.doLogin(username);
List<Role> roleList = roleDao.findRoleByUserId(user.getId());
user.setRoleList(roleList);
org.springframework.security.core.userdetails.User u = new org.springframework.security.core.userdetails.User(user.getUsername(), "{noop}"+user.getPassword(), getAuthority(roleList));
return null; }
controller层:
mapper文件RoleMapper。xml:
<select id="findRoleByUserId" parameterType="java.lang.Integer" resultType="com.whut.bean.Role">
select *from tb_role where id in (select roleId from tb_user_role where userId=#{userID})
</select>
组内项目
登陆实现