小编Kus*_*mal的帖子

如何允许匿名用户仅使用 spring security 访问某个功能

我在我的项目中使用 spring security。我有一个条件,匿名用户应该能够从数据库中读取,而只有授权用户才能添加/更新/删除。我们如何在安全配置中提及这种情况?

.antMatchers("/user/**").permitAll()
Run Code Online (Sandbox Code Playgroud)

permit all 需要经过身份验证,但我什至希望没有经过身份验证的用户通过 GET 方法访问。

@RequestMapping("/user")
@PreAuthorize("hasAuthority('USER')")
public List<UserAll> getAll() {

    return userService.getAll();
}
Run Code Online (Sandbox Code Playgroud)

在这里我如何提到匿名用户也应该访问此功能?

spring spring-security spring-boot

6
推荐指数
1
解决办法
5751
查看次数

如何从jdbc模板查询中提取hashmap对象

我正在尝试从 JDBCTemplate 查询中提取 2 个整数列表/数组。我认为检索 Map 将是最实用的。查询是

Map<Integer, Integer> availabletime = jdbctemp.query("
Select a.hour, 
    s.duration from appointment as a inner join services as s on a.service_fid=s.id 
where date=? and guru_fid=? 
    ",date,guru_fid,//mapperlogic.class);
Run Code Online (Sandbox Code Playgroud)

我需要 a.hour 和 s.duration 作为哈希图的键值对。我对这里的行映射器逻辑有点困惑。到目前为止,我只映射到对象

public class RoleRowMapper implements RowMapper<Role> {

@Override
public Role mapRow(ResultSet row, int rowNum) throws SQLException {
    Role role=new Role();
    role.setId(row.getLong("id"));
    role.setName(row.getString("name"));
    return role;
}
Run Code Online (Sandbox Code Playgroud)

` 有人可以帮助我将查询结果提取到地图或多个列表吗?

java spring jdbc jdbctemplate spring-boot

3
推荐指数
1
解决办法
4904
查看次数

标签 统计

spring ×2

spring-boot ×2

java ×1

jdbc ×1

jdbctemplate ×1

spring-security ×1