欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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登錄的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Java多線程實(shí)現(xiàn)的兩種方式

    Java多線程實(shí)現(xiàn)的兩種方式

    本文主要介紹了Java多線程實(shí)現(xiàn)的兩種方式:繼承Thread類、實(shí)現(xiàn)Runnable接口。具有一定的參考價(jià)值,下面跟著小編一起來看下吧
    2017-01-01
  • Java中四種9*9乘法表的實(shí)現(xiàn)方式(附代碼)

    Java中四種9*9乘法表的實(shí)現(xiàn)方式(附代碼)

    這篇文章主要介紹了Java中四種9*9乘法表的實(shí)現(xiàn)方式(附代碼),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • SpringSecurity的@EnableWebSecurity注解詳解

    SpringSecurity的@EnableWebSecurity注解詳解

    這篇文章主要介紹了SpringSecurity的@EnableWebSecurity注解詳解,@EnableWebSecurity是開啟SpringSecurity的默認(rèn)行為,它的上面有一個(gè)Import注解導(dǎo)入了WebSecurityConfiguration類,就是往IOC容器中注入了WebSecurityConfiguration這個(gè)類,需要的朋友可以參考下
    2023-11-11
  • Java圖像之自定義角度旋轉(zhuǎn)(實(shí)例)

    Java圖像之自定義角度旋轉(zhuǎn)(實(shí)例)

    這篇文章主要介紹了Java圖像之自定義角度旋轉(zhuǎn)(實(shí)例),需要的朋友可以參考下
    2017-09-09
  • Mybatis的TypeHandler加解密數(shù)據(jù)實(shí)現(xiàn)

    Mybatis的TypeHandler加解密數(shù)據(jù)實(shí)現(xiàn)

    在我們數(shù)據(jù)庫中有些時(shí)候會(huì)保存一些用戶的敏感信息,所以就需要對(duì)這些數(shù)據(jù)進(jìn)行加密,那么本文就介紹了Mybatis的TypeHandler加解密數(shù)據(jù)實(shí)現(xiàn),感興趣的可以了解一下
    2021-06-06
  • Java的List集合中泛型使用詳解

    Java的List集合中泛型使用詳解

    這篇文章主要介紹了Java的List集合中泛型使用詳解,泛型類,如果沒有指定具體的數(shù)據(jù)類型,此時(shí),操作類型是Object,泛型的類型參數(shù)只能是類類型,不能是基本數(shù)據(jù)類型,需要的朋友可以參考下
    2023-12-12
  • JAVA  字符串加密、密碼加密實(shí)現(xiàn)方法

    JAVA 字符串加密、密碼加密實(shí)現(xiàn)方法

    這篇文章主要介紹了JAVA 字符串加密、密碼加密實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • Java使用Servlet生成驗(yàn)證碼圖片

    Java使用Servlet生成驗(yàn)證碼圖片

    這篇文章主要為大家詳細(xì)介紹了Java使用Servlet生成驗(yàn)證碼圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • java基本事件處理機(jī)制解析

    java基本事件處理機(jī)制解析

    這篇文章主要介紹了java基本事件處理機(jī)制解析,?Java事件處理機(jī)制是一種用于處理用戶交互和系統(tǒng)事件的編程模型,它基于事件驅(qū)動(dòng)的思想,通過監(jiān)聽和響應(yīng)事件來實(shí)現(xiàn)程序的交互性和動(dòng)態(tài)性,需要的朋友可以參考下
    2023-10-10
  • java微信server錄音下載到自己server

    java微信server錄音下載到自己server

    這篇文章主要為大家詳細(xì)介紹了java微信server錄音下載到自己server的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05

最新評(píng)論