当前位置: 首页 > news >正文

Spring Boot + EasyUI 创建第一个项目(一)

        创建一个Spring Boot和EasyUI相结合的项目。

一、构建一个Spring Boot项目

Spring Boot之创建一个Spring Boot项目(一)-CSDN博客

二、配置Thymeleaf

Spring Boot Thymeleaf(十一)_thymeleaf 设置字体_人……杰的博客-CSDN博客

三、配置EasyUI

1 下载EasyUI的对应jar包并配置使用EasyUI

下载地址:EasyUI框架下载 - EasyUI中文站

 

 

        新建一个index.html文件,注意这个文件需要放在static目录下,也就是跟easyui在同一个目录,否则放在templates下由于springboot的内部机制,调用接口访问不到会报404,结构如上图所示,浏览器访问这个页面的路径是localhost:8080/index.html


引入EasyUI:

    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css"><link rel="stylesheet" type="text/css" href="../../themes/icon.css"><link rel="stylesheet" type="text/css" href="../demo.css"><script type="text/javascript" src="../../jquery.min.js"></script><script type="text/javascript" src="../../jquery.easyui.min.js"></script>

四、项目举例

1 项目框架

2 代码实现

SpringBootMainApplication.java:

package com.xj.main;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;/*** @Author: xjfu* @Create: 2023/10/20 7:33* @Description: SpringBoot启动类*/
@ComponentScan("com.xj")
@SpringBootApplication
public class SpringBootMainApplication {public static void main(String[] args) {try{SpringApplication.run(SpringBootMainApplication.class, args);}catch (Exception e){e.printStackTrace();}}
}

ThymeleafController.java:

package com.xj.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;/*** @Author: xjfu* @Create: 2023/10/20 7:42* @Description:*/
@RequestMapping("/easyui")
@Controller
public class ThymeleafController {@RequestMapping("/hello")public String sayHello(){//启动hello.html页面return "hello";}@RequestMapping("/helloPage")public String helloPage(){//启动helloPage.html页面return "helloPage";}
}

index.html:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Custom Window Tools - jQuery EasyUI Demo</title><link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css"><link rel="stylesheet" type="text/css" href="../../themes/icon.css"><link rel="stylesheet" type="text/css" href="../demo.css"><script type="text/javascript" src="../../jquery.min.js"></script><script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<div id="win" class="easyui-window" title="My Window" style="width:300px;height:100px;padding:5px;">Hello! Sprring Boot + easyUI success!
</div>
</body>
</html>

hello.html:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body>
<!--th:text 为 Thymeleaf 属性,用于在展示文本-->
<h1 th:text="迎您来到Thymeleaf">欢迎您访问静态页面 HTML</h1>
</body>
</html>

helloPage.html:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Custom Window Tools - jQuery EasyUI Demo</title><link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css"><link rel="stylesheet" type="text/css" href="../../themes/icon.css"><link rel="stylesheet" type="text/css" href="../demo.css"><script type="text/javascript" src="../../jquery.min.js"></script><script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<div id="win" class="easyui-window" title="My Window" style="width:300px;height:100px;padding:5px;">Hello! Sprring Boot + easyUI success!
</div>
</body>
</html>

3 运行结果

3.1 测试thymeleaf正常

3.2 EasyUI访问方式

3.3 使用thymeleaf访问方式

五、参考

1.SpringBoot集成EasyUI_springboot整合easyui-CSDN博客

2.https://www.cnblogs.com/jingmoxukong/p/10239821.html

3.Easyui 创建简单窗口_EasyUI 教程

http://www.lryc.cn/news/204047.html

相关文章:

  • 短视频矩阵系统源码/技术应用搭建
  • 硬核子牙:我准备写一本《带你手写64位多核操作系统》的书!
  • c++访问修饰符与继承关系
  • 【RTOS学习】事件组 | 任务通知
  • 【TES605】基于Virtex-7 FPGA的高性能实时信号处理平台
  • Java Azure开发 使用已有token字符串创建GraphServiceClient
  • 【Qt】消息机制和事件
  • 爬虫模拟用户登录
  • asp.net企业招聘管理系统VS开发sqlserver数据库web结构c#编程Microsoft Visual Studio计算机毕业设计
  • 艾泊宇产品战略:假如中国禁止直播带货,网红和店家该如何应对?
  • C#调用C/C++从零深入讲解
  • MyBatis篇---第五篇
  • 十三水中各种牌型判断LUA版
  • 2023.10.19 关于设计模式 —— 单例模式
  • 4个鲜为人知的Python迭代过滤函数
  • 使用logger.error(“自定义错误信息描述“,e)将错误信息输出到日志文件上
  • 音乐的数字未来:虚拟演唱会与TikTok的巅峰融合
  • 基于图像识别的跌倒检测算法 计算机竞赛
  • NSS [SWPUCTF 2021 新生赛]PseudoProtocols
  • 字节码进阶之JVM Attach API详解
  • Kubernetes 部署 kubeflow1.6.1
  • 设计模式:建造者模式(C#、JAVA、JavaScript、C++、Python、Go、PHP)
  • Maxon Cinema 4D 2024:打造独一无二的视觉效果 模拟模块大更新
  • 16.2 ARP 主机探测技术
  • 三级等保-linux服务器三权分立设置
  • 抓取网页的含义和URL基本构成
  • 计算机毕业设计 机器学习深度学习人工智能
  • 施密特正交化
  • 低代码开发:加速应用开发的利器
  • 数据安全发展趋势与密码保护技术研究