SpringBoot框架写的JavaWeb程序,从前端到数据库,操作流程(html controller service mapper DB)

本文详细阐述了一个SpringBoot框架下JavaWeb程序的完整操作流程,从前端HTML页面到数据库的交互。讲解了entity实体类、HTML、controller、service接口及实现、Mapper接口与XML实现,强调了不同情况下@注解与复杂SQL语句的使用策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JavaWeb程序 从前端到数据库,操作流程(html controller service mapper DB)

传递流程图

在这里插入图片描述

代码讲解

entity实体类

因为都有id字段
所以单独一个BaseEntity类
其他entity都有主键,所以直接继承就可以,

BaseEntity:

/**
 * 主键类
 * @Author: yibox
 */
@Data
public class BaseEntity {
   
    private long id;
}

这篇博客用到的
PageView 实体类

/**
 * t_page_view实体类
 * @Author: yibox
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PageView extends BaseEntity {
   
    private Integer pageView;
    private LocalDateTime createTime;
}

html代码

  1. url:对应controller
    @ResponseBody
    @PostMapping("/getPageView/{type}")
  2. type:对应Post请求
    @PostMapping
  3. dataType:“json”,对应返回值类型
<script>
$(function () {
    
 $.ajax({
    
       url:"/admin/getPageView/month",
       type:"post",
       dataType:"json",
       success:function(data){
    
			
			console.log(data);
			
       }
   });
});
</script>

controller代码


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值