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

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.kler.cn/a/105061.html

相关文章:

  • 聊聊“JVM 调优JVM 性能优化”是怎么个事?
  • Server Name Indication(SNI),HTTP/TLS握手过程解析
  • Hafnium安全分区管理器和示例参考软件栈
  • DB-GPT发布:用私有LLM技术彻底改革数据库互动
  • 【软件测试】了解JUnit单元测试框架常用注解
  • 导致爬虫无法使用的原因有哪些?
  • spring cloud Eureka集群模式搭建(IDEA中运行)《二》
  • 0036【Edabit ★☆☆☆☆☆】【让我加油】Let‘s Fuel Up!
  • 项目管理之如何有效定义项目目标
  • Android12 启动页适配
  • PX4天大bug,上电反复重启,连不上QGC!
  • 【openGauss】一主一备实现主备节点切换实验(switchover、failover)
  • 2023全新TwoNav开源网址导航系统源码 | 去授权版
  • MySQL数据库备份实战
  • 打破总分行数据协作壁垒,DataOps在头部股份制银行的实践|案例研究
  • KMS在腾讯云的微服务实践助力其降本50%
  • 单例模式及其使用场景
  • RSAUtil 前端 JavaScript JSEncrypt 实现 RSA (长文本)加密解密
  • 【20年VIO梳理】
  • SpringMVC 异常处理器