码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 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:

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

    四、项目举例

    1 项目框架

    2 代码实现

    SpringBootMainApplication.java:

    1. package com.xj.main;
    2. import org.springframework.boot.SpringApplication;
    3. import org.springframework.boot.autoconfigure.SpringBootApplication;
    4. import org.springframework.context.annotation.ComponentScan;
    5. /**
    6. * @Author: xjfu
    7. * @Create: 2023/10/20 7:33
    8. * @Description: SpringBoot启动类
    9. */
    10. @ComponentScan("com.xj")
    11. @SpringBootApplication
    12. public class SpringBootMainApplication {
    13. public static void main(String[] args) {
    14. try{
    15. SpringApplication.run(SpringBootMainApplication.class, args);
    16. }catch (Exception e){
    17. e.printStackTrace();
    18. }
    19. }
    20. }

    ThymeleafController.java:

    1. package com.xj.controller;
    2. import org.springframework.stereotype.Controller;
    3. import org.springframework.web.bind.annotation.RequestMapping;
    4. /**
    5. * @Author: xjfu
    6. * @Create: 2023/10/20 7:42
    7. * @Description:
    8. */
    9. @RequestMapping("/easyui")
    10. @Controller
    11. public class ThymeleafController {
    12. @RequestMapping("/hello")
    13. public String sayHello(){
    14. //启动hello.html页面
    15. return "hello";
    16. }
    17. @RequestMapping("/helloPage")
    18. public String helloPage(){
    19. //启动helloPage.html页面
    20. return "helloPage";
    21. }
    22. }

    index.html:

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Custom Window Tools - jQuery EasyUI Demotitle>
    6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
    7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    8. <link rel="stylesheet" type="text/css" href="../demo.css">
    9. <script type="text/javascript" src="../../jquery.min.js">script>
    10. <script type="text/javascript" src="../../jquery.easyui.min.js">script>
    11. head>
    12. <body>
    13. <div id="win" class="easyui-window" title="My Window" style="width:300px;height:100px;padding:5px;">
    14. Hello! Sprring Boot + easyUI success!
    15. div>
    16. body>
    17. html>

    hello.html:

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. head>
    7. <body>
    8. <h1 th:text="迎您来到Thymeleaf">欢迎您访问静态页面 HTMLh1>
    9. body>
    10. html>

    helloPage.html:

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Custom Window Tools - jQuery EasyUI Demotitle>
    6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
    7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    8. <link rel="stylesheet" type="text/css" href="../demo.css">
    9. <script type="text/javascript" src="../../jquery.min.js">script>
    10. <script type="text/javascript" src="../../jquery.easyui.min.js">script>
    11. head>
    12. <body>
    13. <div id="win" class="easyui-window" title="My Window" style="width:300px;height:100px;padding:5px;">
    14. Hello! Sprring Boot + easyUI success!
    15. div>
    16. body>
    17. 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 教程

  • 相关阅读:
    AxureRP制作静态站点发布互联网,实现公网访问【内网穿透】
    [管理与领导-102]:经营与管理的关系:攻守关系;武将文官关系;开疆拓土与守护城池的关系;战斗与练兵的关系;水涨船高,水落船低的关系。
    day47:C++ day7,异常处理、using的第三种用法、类型转换、lambda表达式、STL标准模板库
    最长回文子串
    鲜花商城|基于Springboot实现鲜花商城系统
    剑指offer 40. 数组中出现次数超过一半的数字
    软件工程——名词解释
    JAVA——》模拟虚拟机栈溢出
    详解 HBase 的常用 API
    郑州直销系统开发为什么需要不断地过滤人?
  • 原文地址:https://blog.csdn.net/qq_21370419/article/details/125420740
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号