欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

Java

當(dāng)前位置:主頁 > 軟件編程 > Java >

Spring Security跳轉(zhuǎn)頁面失敗問題解決

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:Java|點(diǎn)擊: 次

這篇文章主要介紹了Spring Security跳轉(zhuǎn)頁面失敗問題解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

今天新建SpringBoot項(xiàng)目練手,第一次添加了Spring Security.成功啟動(dòng)項(xiàng)目后發(fā)現(xiàn)與之前新建的項(xiàng)目有點(diǎn)不一樣,無論我怎么設(shè)置系統(tǒng)首頁,瀏覽器內(nèi)打開的都是登陸界面,如圖:

無論我怎么設(shè)置controller的跳轉(zhuǎn)路徑都不起作用,氣到撓頭?。?!

經(jīng)過查閱各種資料發(fā)現(xiàn)可能是Spring Security權(quán)限控制的原因,于是著手配置控制權(quán)限。

新建SecurityConfig類進(jìn)行權(quán)限配置,代碼如下:

import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    //配置資源文件,其中/css/**、index可以任意訪問
    http
        .authorizeRequests()
        .antMatchers("/css/**", "/index").permitAll();
  }

}

一些解釋:

  • authorizeRequests: 配置一些資源或者鏈接的權(quán)限認(rèn)證
  • antMatchers:配置哪些資源或鏈接需要被認(rèn)證
  • permitAll:設(shè)置完全允許訪問的資源或者鏈接

添加上述權(quán)限設(shè)置后index頁面可以正常訪問

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:Spring Boot定時(shí)+多線程執(zhí)行過程解析

欄    目:Java

下一篇:Jmeter調(diào)用java腳本過程詳解

本文標(biāo)題:Spring Security跳轉(zhuǎn)頁面失敗問題解決

本文地址:http://mengdiqiu.com.cn/a1/Java/8774.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有