zoukankan      html  css  js  c++  java
  • Springboot

    1.静态资源引入-------   存放查找路径:

    spring.mvc.static-path-pattern=/**

    spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/,classpath:/public/
    2.配置文件引入:

    yaml   注解: @ConfigurationProperties(prefix="xxx")

    properties    注解:@PropertySource(value="相对路径") @Value("${xx}")

    注:配置插件 springassist  提示yaml 和properties 配置文件的提示信息

    3.添加@Transactional  @Slf4j的用法  service 层 和 controller 打印日志

    4.thymeleaf 页面

    模板替换 :模板页面header.html    <header th:replace="header::html></header> 替换header标签调用header.html

    <link rel="stylesheet" th:href="@{/.../font.css}">  /代表/static/ 目录    @{}加双引号

    thymeleaf 扩展shiro支持:
    
    1.<dependency>
        <groupId>com.github.theborakompanioni</groupId>
        <artifactId>thymeleaf-extras-shiro</artifactId>
        <version>2.0.0</version>
    </dependency>
    2.配置shirodialect 对象。在shiroConfig中
    3.增加shiro:hasPermssion="roles"标签属性。

    5.shiro-springboot的配置流程

    1.导入springboot支持的shiro包 
    shiro-spring-boot-web-starter
    2.配置shiroConfiger类
        1.配置shiroFilterFactoryBean类
        2.配置DefaultShirowebSecurityManager类
        3.配置继承AutorizaingRealm抽象类的自定义类UserRealm并实现
         doGetAuthorizationInfo  
        授权需要注意:Subject subject = SecurityUtils.getSubject();
        subject.getprincipal()
    simpleAuthorizationInfo.addStringPermission(user.getPerms());
    doGetAuthenticationInfo 方法
          获取token  包含前端传递的username和password
    new SimpleAuthenticationInfo(user,user.getPassword(),"")
      controller里:
    Subject subject = SecurityUtils.getSubject();
     UsernamePasswordToken token = new UsernamePasswordToken(username, password);
    
        4.还可以配置ShiroDialect类
    
    
  • 相关阅读:
    ICMP协议
    观察者模式-Observer
    模板方法模式-Template Method
    Java的演变过程
    汉诺塔-Hanoi
    外观模式-Facade
    JDK5-增强for循环
    JDK5-可变参数
    动态代理与AOP
    代理模式-Proxy
  • 原文地址:https://www.cnblogs.com/chencn/p/12410819.html
Copyright © 2011-2022 走看看