layui请求加token_layui的一个登录和权限示例

layui是一个专门为后台而设计的一个前端框架,功能强大,特别适合后端开发人员,本文以一个demo把登录模块和权限模块基本原理说明,详细的内容可以参考layui的官方文档,git地址

搭建项目

项目架构是springboot+thymeleaf+layui,结构如下图,文件有点多,分成两张图

image.png

image.png

其中resources资源文件里的layui文件夹下就是layui的所有文件,内容需要到官网下载,解压后全部复制即可

pom.xml

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.1.2.RELEASE

com.haijunyin

layuidemo-permission

0.0.1-SNAPSHOT

layuidemo-permission

Demo project for Spring Boot

war

1.8

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

javax.servlet

javax.servlet-api

4.0.0

provided

org.thymeleaf

thymeleaf

3.0.11.RELEASE

org.thymeleaf

thymeleaf-spring4

3.0.11.RELEASE

org.springframework.boot

spring-boot-starter-thymeleaf

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

application.properties

#thymelea模板配置

xspring.thymeleaf.prefi=classpath:/templates/

spring.thymeleaf.suffix=.html

spring.thymeleaf.mode=HTML5

spring.thymeleaf.encoding=UTF-8

#热部署文件,页面不产生缓存,及时更新

spring.thymeleaf.cache=false

spring.resources.chain.strategy.content.enabled=true

spring.resources.chain.strategy.content.paths=/**

LayuidemoPermissionApplication.java

package com.haijunyin.layuidemo.permission;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.scheduling.annotation.EnableAsync;

/**

* 继承SpringBootServletInitializer,因为继承SpringBootServletInitializer是继承WebApplicationInitializer的,而servlet容器启动的时候

* 会将WebApplicationInitializer相关的所有子类实例化(这也是servlet3.0以上的版本提供支持),所以我们还需要在pom.xml

* 文件中导入servlet3.0及以上的版本

*/

@ComponentScan(value = "com.haijunyin.layuidemo.permission")

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

@EnableAsync

public class LayuidemoPermissionApplication extends SpringBootServletInitializer{

@Override

public SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

return builder.sources(LayuidemoPermissionApplication.class);

}

public static void main(String[] args) {

SpringApplication.run(LayuidemoPermissionApplication.class, args);

}

}

admin_user_list.html

layui在线调试

body{margin: 10px;}

.demo-carousel{height: 200px; line-height: 200px; text-align: center;}

查看

编辑

删除

  • 演示说明
  • 日期
  • 分页
  • 上传
  • 滑块

点击上传,或将文件拖拽到此处

layui.config({

version: '1545041465480' //为了更新 js 缓存,可忽略

});

layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function(){

var laydate = layui.laydate //日期

,laypage = layui.laypage //分页

,layer = layui.layer //弹层

,table = layui.table //表格</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值