第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

403 Forbidden 即使我授予訪問權(quán)限

403 Forbidden 即使我授予訪問權(quán)限

慕娘9325324 2023-05-24 15:16:51
我使用 spring security 創(chuàng)建了一個(gè)項(xiàng)目。在configure(HttpSecurity http)我為用戶設(shè)置訪問"/home"權(quán)限時(shí),但在我登錄后,它顯示:403禁止訪問我創(chuàng)建了一個(gè)Entity class named User implementing UserDetails并且getAuthorities()我只是重新運(yùn)行Arrays.asList(new SimpleGrantedAuthority("USER"));對(duì)于 http 對(duì)象,我嘗試使用直接.hasRole('USER')方法而不是.access("hasRole('USER')"),問題是一樣的。@Overrideprotected void configure(HttpSecurity http) throws Exception{    http        .authorizeRequests()         .antMatchers("/home")          .access("hasRole('USER')")          .antMatchers("/","/**").access("permitAll")          .anyRequest().authenticated()          .and()            .formLogin()            .and()        .httpBasic();}
查看完整描述

1 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

您需要使用權(quán)限而不是角色。


@Override

protected void configure(HttpSecurity http) throws Exception {

http

    .authorizeRequests()

     .antMatchers("/home").hasAuthority("USER")

      .antMatchers("/","/**").access("permitAll")

      .anyRequest().authenticated()

      .and()

        .formLogin()

        .and()

    .httpBasic();

}


查看完整回答
反對(duì) 回復(fù) 2023-05-24
  • 1 回答
  • 0 關(guān)注
  • 170 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)