GithubHelp home page GithubHelp logo

muku-blog's Introduction

BUG

  • !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • 虽然这个bug解决起来很快.但是.我只能说..好难受的bug.
  • Controller中,无论是不是根路径,都需要指定一个"/",不然可能会出现F12后.告诉你静态文件类型不对的错误.

奇淫巧技

  • ResponseEntity. 该类可以无需在方法上加@ResponseBody注解,然后返回实体和状态码

  • 直接在resources/static下放上名为favicon.ico,即可改变网站图标

  • @AutoConfigureMockMvc

Thymeleaf和SpringBoot集成

  1. 引入依赖

compile('org.springframework.boot:spring-boot-starter-thymeleaf')

  1. 修改默认thymeleaf版本,在buildscript{...}增加
//自定义thymeleaf和它的方言的版本.因为默认版本比较低
ext['thymeleaf.version'] = '3.0.3.RELEASE'
ext['thymeleaf-layout-dialect.version'] = '2.2.0'
  1. 可直接在项目根目录输入gradlew bootRun 启动项目
  2. yml中如下设置:
spring:
  thymeleaf:
    encoding: UTF-8
    #热部署静态文件
    cache: false
    #使用html5标准,默认就是
    mode: HTML5

Thymeleaf用户管理页面搭建

  • 页面需要导入的命名空间:
<html xmlns:th="http://www.thymeleaf.org"
    xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">    

H2内嵌数据库

  1. 导入依赖
	runtime group: 'com.h2database', name: 'h2', version: '1.4.196'
  1. 无需配置dataSource即可运行程序
  2. (貌似不需要)在中配置:
spring:
  h2:
    console:
      enabled: true
  1. 可查看/h2-console,查看其内存数据库中的数据

前端框架

IDEA GRADLE springBoot 热部署

  1. compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '1.4.3.RELEASE'
  2. build.gradle
bootRun {   
      addResources = true
}
  1. 使用bootRun运行(命令行是 gradlew bootRun)
  2. idea的设置中的Complier中的自动编译勾上
  3. ctrl + shift + alt + /,选择registry... , 勾上 when.app.runing

SpringSecurity 和 Thymeleaf

  1. 导入依赖
	compile('org.springframework.boot:spring-boot-starter-security')
	compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.2.RELEASE')
  1. 配置类
  2. 在页面导入命名空间

xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"

总结

这个教程买得贼亏,就照着写了前面的一点,几乎没有什么出彩的地方. 后面那老师自己都是狂粘贴.我全部快进看了.一无是处.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.