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

IDEA运行thymeleaf的html文件打开端口为63342且连不上数据库

这边贴apple.html代码

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>User List</title>
</head>
<body>
<h1>User List</h1>
<table><tr><th>ID</th><th>Name</th></tr><tr th:each="apple : ${apple}"><td th:text="${apple.number}"></td><td th:text="${apple.price}"></td></tr>
</table>
</body>
</html>

运行效果这样
在这里插入图片描述
也没有报错,就是没法展现数据库内容,这边问题为不要在html界面直接运行
先运行项目创建时自带的AppleDashboardApplication,项目启动后,也就执行了其他的类,开启了服务器8080端口
在这里插入图片描述
总结一下:直接运行html文件就没有执行运行其他类的一个过程,因此要先运行总的AppleDashboardApplication,再根据controller包内部指定的RequestMapping跳转到具体页面
这边放一下controller包内代码

package com.appledashboard.controller;import com.appledashboard.po.Apple;
import com.appledashboard.service.AppleServicesImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.List;
@Controller
public class AppleController {@AutowiredAppleServicesImpl appleServicesImpl;@RequestMapping("/apple")public String apple(Model model){List<Apple> apple = appleServicesImpl.queryAll();model.addAttribute("apple", apple);return "apple";}
}

运行结果:
在这里插入图片描述

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

相关文章:

  • sql报错注入和联合注入
  • 028 - STM32学习笔记 - ADC结构体学习(二)
  • Pytest自动化测试框架:mark用法---测试用例分组执行
  • 【TCP连接的状态】
  • Node.js入门指南(一)
  • 使用Grpc实现高性能PHP RPC服务
  • 二、爬虫-爬取肯德基在北京的店铺地址
  • linux驱动开发.之spi测试工具spidev_test源码(一)
  • 基于材料生成算法优化概率神经网络PNN的分类预测 - 附代码
  • Go——二、变量和数据类型
  • 合并区间问题
  • 2023 年最新 MySQL 数据库 Windows 本地安装、Centos 服务器安装详细教程
  • 每天一道算法题(十)——获取和为k的子数组
  • 2023年亚太杯数学建模思路 - 案例:最短时间生产计划安排
  • 在vscode中使用Latex:TexLive2023
  • Unity开发之C#基础-File文件读取
  • 深度学习之二(前馈神经网络--Feedforward Neural Network)
  • 2023全球边缘计算大会深圳站-核心PPT资料下载
  • 【亚太杯思路助攻】2023年第十三届APMCM亚太地区大学生数学建模竞赛——(文末领取方式)
  • vue开发一、在Vue中引入ElementUI二、在Vue中使用阿里图标库
  • 基于SpringBoot+Mybatis plus+React.js实现条件选择切换搜索功能
  • 【STM32】W25Q64 SPI(串行外设接口)
  • 如何使用Mondo Rescue备份及恢复Linux系统(制作ISO镜像,成功恢复)
  • Java如何获取泛型类型
  • 2023年【起重机械指挥】考试题及起重机械指挥找解析
  • 【前端学java】Java中的接口和枚举概念(7)
  • P8611 [蓝桥杯 2014 省 AB] 蚂蚁感冒(模拟)
  • 边缘计算是如何为元宇宙提供动力的?
  • 优秀智慧园区案例 - 上海世博文化公园智慧园区,先进智慧园区建设方案经验
  • 【DevOps】Git 图文详解(五):远程仓库