栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

spring boot+thymeleaf+bootstrap实现后台管理系统界面

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring boot+thymeleaf+bootstrap实现后台管理系统界面

最近在学spring boot ,学习一个框架无非也就是使用它来做以前做的事情,两者比较才有不同,说一下自己使用的体会。
先来说下spring boot ,微框架。快速开发,相当于零配置,从一个大神那看来的说:spring boot 相当于框架的框架 ,就是集成了很多,用哪个添加哪个的依赖就行,这样的话自己看不到配置,对于习惯了使用配置刚使用spring boot的开发者来说可能还有点不习惯,什么都不用配,看不到配置感觉对项目整体架构有点陌生,再说在spring boot 中使用 thymeleaf 。就拿个最简单的例子来说明 jsp显示helloworld , thymeleaf显示helloworld,两者也就pom文件引入依赖和属性文件配置不同,在你使用jsp的时候不要引入thymeleaf的依赖,当然在使用thymeleaf的时候也不要引入jsp的依赖 有可能会产生冲突,spring boot 官方是推荐使用thymeleaf 我个人感觉也不错,开始项目吧!

1 、首先 建一个meaven项目 看一下建好的项目整体结构

建好项目结构弄pom.xml ,这个demo只用到thymeleaf,没有数据库方面的依赖,所需依赖很少

 
 4.0.0 
 Springboot_bootstrap 
 Springboot_bootstrap 
 0.0.1-SNAPSHOT 
  
 org.springframework.boot 
 spring-boot-starter-parent 
 1.4.7.RELEASE 
   
  
 
  
 UTF-8 
 UTF-8 
 1.8 
  
 
  
  
 org.springframework.boot 
 spring-boot-starter 
  
 
  
 org.springframework.boot 
 spring-boot-starter-web 
  
 
  
 
  
 org.springframework.boot 
 spring-boot-starter-thymeleaf 
  
 
  
 
  
  
  
 org.springframework.boot 
 spring-boot-maven-plugin 
  
  
  
 

在src /main/resource 建立 application.properties文件

server.port=8080 
server.session.timeout=10 
server.tomcat.uri-encoding=UTF-8 
 
spring.thymeleaf.prefix=classpath:/views/ 
spring.thymeleaf.suffix=.html 
spring.thymeleaf.mode=HTML5 
spring.thymeleaf.encoding=UTF-8 
spring.thymeleaf.content-type=text/html 
spring.thymeleaf.cache=false 

写入口程序

package com.zanghan.youyu; 
 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
 
@SpringBootApplication 
public class YouYuApplication { 
 
 public static void main(String[] args) { 
 SpringApplication.run(YouYuApplication.class, args); 
 } 
} 

控制器跳转bootstrap界面

package com.zanghan.youyu.controller; 
 
import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping; 
 
@Controller 
public class LoginController { 
 @RequestMapping("/") 
 public String index(){ 
 return "/index"; 
 } 
} 

引入bootstrap js css 放在哪里?放在static文件夹里,views中放的是页面

index.html界面存放在 src/main/resource 下的views 文件夹里,为啥不是tepmlates 因为在属性配置文件中写的是views ,thymeleaf 的前缀和后缀都可以改变的

 
 
 
  
  
  
 MES平台 
  
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
 body { 
 font-size: 12px; 
 } 
 
 .nav > li > a { 
 padding: 5px 10px; 
 } 
 
 .tab-content { 
 padding-top: 3px; 
 } 
  
 
 
  
 
  
  
  
  
  
 
  
  
 
  
   
   
  
  
 
  
  
  
   
   
   
   
   
  欢迎进入后台管理系统 
   
   
   
   
  
  
 
  
 
  
  
  
  
 
 

搞定,运行application 输入localhost:8080

更多学习资料请关注专题《管理系统开发》。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/142869.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号