最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot整合Security權(quán)限控制登錄首頁

 更新時(shí)間:2022年11月11日 16:16:28   作者:EdurtIO  
這篇文章主要為大家介紹了SpringBoot整合Security權(quán)限控制登錄首頁示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

在 pom 文件中增加thymeleaf頁面支持

<!-- 引入頁面模板 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

application.yml 配置文件

創(chuàng)建 resources 目錄文件夾目錄為: src/main/resources 并將其設(shè)置為 resource 資源目錄, 在resources目錄下創(chuàng)建 application.yml 配置文件

spring:
  thymeleaf:
    cache: false
    check-template: true
    check-template-location: true
    content-type: text/html
    enabled: true
    encoding: UTF-8
    mode: HTML5
    prefix: classpath:/templates/
    suffix: .html

在resources目錄下創(chuàng)建 templates 文件目錄, 并在該目錄下創(chuàng)建 index.html 和 login.html 頁面文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>SpringBoot Security Integration</title>
</head>
<body>
</body>
</html>

login 頁面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>登錄頁面</title>
</head>
<body>
<form action="" method="post">
    <table>
        <tr>
            <td>用戶名:</td>
            <td><input name="username" id="username" value=""/></td>
        </tr>
        <tr>
            <td>密碼:</td>
            <td><input name="password" id="password" value=""/></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="submit" /></td>
        </tr>
    </table>
</form>
</body>
</html>

controller目錄下跳轉(zhuǎn)配置

在 java 源碼目錄下創(chuàng)建controller目錄, 并在該目錄下創(chuàng)建 HomeController/UserController 進(jìn)行頁面跳轉(zhuǎn)配置

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edurt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
 * HomeController 
 * 描述 : HomeController 
 * 作者 : qianmoQ 
 * 版本 : 1.0 
 * 創(chuàng)建時(shí)間 : 2018-03-20 下午2:24 
 */
@Controller
public class HomeController {
    /**
     * 首頁
     *
     * @return 首頁頁面跳轉(zhuǎn)
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    String home() {
        return "index";
    }
}

UserController

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edurt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
 * UserController 
 * 描述 : UserController 
 * 作者 : qianmoQ 
 * 版本 : 1.0 
 * 創(chuàng)建時(shí)間 : 2018-03-20 下午2:24 
 */
@Controller
@RequestMapping(value = "user")
public class UserController {
    /**
     * 用戶登錄
     *
     * @return 用戶登錄頁面跳轉(zhuǎn)
     */
    @RequestMapping(value = "login", method = RequestMethod.GET)
    String login() {
        return "login";
    }
    /**
     * 用戶注銷退出
     *
     * @return 用戶注銷退出頁面跳轉(zhuǎn)
     */
    @RequestMapping(value = "logout", method = RequestMethod.GET)
    String logout() {
        return "login";
    }
}

以上就是SpringBoot整合Security權(quán)限控制登錄首頁的詳細(xì)內(nèi)容,更多關(guān)于SpringBoot整合Security登錄的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • JAVA不可變類(immutable)機(jī)制與String的不可變性(推薦)

    JAVA不可變類(immutable)機(jī)制與String的不可變性(推薦)

    這篇文章主要介紹了JAVA不可變類(immutable)機(jī)制與String的不可變性(推薦)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-08-08
  • IDEA在Maven項(xiàng)目中使用本地jar包的方法

    IDEA在Maven項(xiàng)目中使用本地jar包的方法

    我們在拿到舊項(xiàng)目的時(shí)候,經(jīng)常會遇到一種情況,就是這個(gè)項(xiàng)目的maven中依賴了一個(gè)本地的jar包,這種情況就需要引入這個(gè)jar包,所以本文給大家介紹了IDEA在Maven項(xiàng)目中使用本地jar包的方法,需要的朋友可以參考下
    2024-04-04
  • JAVA開發(fā)環(huán)境Vs?code配置步驟詳解

    JAVA開發(fā)環(huán)境Vs?code配置步驟詳解

    這篇文章主要為大家介紹了JAVA開發(fā)環(huán)境Vs?code配置步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-04-04
  • 解決Spring?Boot應(yīng)用打包后文件訪問問題

    解決Spring?Boot應(yīng)用打包后文件訪問問題

    在Spring Boot項(xiàng)目的開發(fā)過程中,一個(gè)常見的挑戰(zhàn)是如何有效地訪問和操作資源文件,本文就來介紹一下解決Spring?Boot應(yīng)用打包后文件訪問問題,感興趣的可以了解一下
    2024-01-01
  • 詳解如何在Java中實(shí)現(xiàn)懶加載

    詳解如何在Java中實(shí)現(xiàn)懶加載

    懶加載是一種常見的優(yōu)化技術(shù),它可以延遲對象的創(chuàng)建或初始化,直到對象第一次被使用時(shí)才進(jìn)行。在本文中,我們將介紹如何使用?Java?中的?Supplier?接口和雙重檢查鎖定模式來實(shí)現(xiàn)懶加載,并保證只初始化一次,希望對大家有所幫助
    2023-03-03
  • Eclipse導(dǎo)入項(xiàng)目報(bào)錯(cuò)問題解決方案

    Eclipse導(dǎo)入項(xiàng)目報(bào)錯(cuò)問題解決方案

    這篇文章主要介紹了Eclipse導(dǎo)入項(xiàng)目報(bào)錯(cuò)問題解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Java多線程之線程池七個(gè)參數(shù)詳解

    Java多線程之線程池七個(gè)參數(shù)詳解

    這篇文章主要介紹了Java多線程之線程池七個(gè)參數(shù)詳解,文中有很詳細(xì)的代碼示例,對正在學(xué)習(xí)java的小伙伴們有很好的幫助,需要的朋友可以參考下
    2021-04-04
  • Java多種方法實(shí)現(xiàn)合并多個(gè)list對象列表

    Java多種方法實(shí)現(xiàn)合并多個(gè)list對象列表

    Java編程中,合并多個(gè)列表對象可以通過Stream?API或傳統(tǒng)循環(huán)方式實(shí)現(xiàn),使用Stream?API合并時(shí),利用flatMap方法將嵌套的List展平,再通過collect方法收集成一個(gè)新的列表,傳統(tǒng)循環(huán)則通過創(chuàng)建一個(gè)空的ArrayList,并通過遍歷每個(gè)列表將元素添加進(jìn)去
    2024-09-09
  • 解決java攔截器獲取POST入?yún)?dǎo)致@RequestBody參數(shù)丟失問題

    解決java攔截器獲取POST入?yún)?dǎo)致@RequestBody參數(shù)丟失問題

    文章講述了在Java開發(fā)中使用攔截器獲取POST請求入?yún)r(shí),由于流關(guān)閉導(dǎo)致`@RequestBody`參數(shù)丟失的問題,并提出了一種解決方案,解決方案包括自定義方法、防止流丟失、過濾器和攔截器的合理組織和使用,最終確保了參數(shù)的正確傳遞
    2024-11-11
  • Java通過反射將 Excel 解析成對象集合實(shí)例

    Java通過反射將 Excel 解析成對象集合實(shí)例

    這篇文章主要介紹了Java通過反射將 Excel 解析成對象集合實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08

最新評論

自贡市| 米易县| 浠水县| 达日县| 揭东县| 阜阳市| 龙川县| 青铜峡市| 随州市| 纳雍县| 出国| 雅江县| 托里县| 石景山区| 东丰县| 鄱阳县| 来凤县| 松江区| 陵川县| 香河县| 朝阳区| 永靖县| 志丹县| 大关县| 灵川县| 洛阳市| 镇赉县| 长治县| 遂宁市| 莲花县| 专栏| 冷水江市| 双鸭山市| 德州市| 忻州市| 西昌市| 鸡西市| 涿州市| 丹江口市| 阿克陶县| 灵山县|