SSM的前端使用ajax json向后端传值 接收不到或者值缺少问题3种方式 解决

本文讲述了作者在前端调试中遇到的JSON数据在后端接收时出现问题,通过排查发现驼峰命名的实体类属性在后端解析时失效。解决办法包括修改实体类属性为下划线命名,自定义set方法,以及使用Jackson的@JsonProperty注解。

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

找这个bug 找了3小时 o(╥﹏╥)o

第一种

前端debug console data 发现值获取正确

到后端发现 接受值有null 值 明明传过来了。。。。。。。。

1. 前端值正确

2. 后端 有null值

仔细查看数据库发现 有下划线

修改实体类 驼峰命名的实体类属性 

 再次发送

<%--
  Created by IntelliJ IDEA.
  User: 10202
  Date: 2022/4/27
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="style.css">

    <title>登录:界面</title>
    <style>
        /* 清除浏览器默认边距,
使边框和内边距的值包含在元素的width和height内 */

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* 使用flex布局,让内容垂直和水平居中 */

        section {
            /* 相对定位 */
            position: relative;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            /* linear-gradient() 函数用于创建一个表示两种或多种颜色线性渐变的图片 */
            background: linear-gradient(to bottom, #f1f4f9, #dff1ff);
        }

        /* 背景颜色 */

        section .color {
            /* 绝对定位 */
            position: absolute;
            /* 使用filter(滤镜) 属性,给图像设置高斯模糊*/
            filter: blur(200px);
        }

        /* :nth-child(n) 选择器匹配父元素中的第 n 个子元素 */

        section .color:nth-child(1) {
            top: -350px;
            width: 600px;
            height: 600px;
            background: #ff5d0e;
        }

        section .color:nth-child(2) {
            bottom: -150px;
            left: 100px;
            width: 500px;
            height: 500px;
            background: #fffd87;
        }

        section .color:nth-child(3) {
            bottom: 50px;
            right: 100px;
            width: 500px;
            height: 500px;
            background: #1fffd1;
        }

        .box {
            position: relative;
        }

        /* 背景圆样式 */

        .box .circle {
            position: absolute;
            background: rgba(255, 255, 255, 0.1);
            /* backdrop-filter属性为一个元素后面区域添加模糊效果 */
            backdrop-filter: blur(5px);
            box-shadow: 0 25px 45px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.5);
            border-right: 1px solid rgba(255, 255, 255, 0.2);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
          
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kjshuan

点个赞就好啦!!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值