Spring Security-6:登录使用 body JSON 传参

Qoder+IDEA+Spring Boot:基于MCP协议的Agentic编码实践 Agentic编码是一种将AI编程从‘代码补全’升级为‘规划-执行-验证’闭环的新范式,其核心依赖于结构化开发意图表达与项目上下文深度感知。MCP协议作为语义层通信标准,使IDE与AI助手能精准传递技术约束与工程上下文,显著提升生成代码的可追溯性与可维护性。在Spring Boot生态中,这种能力体现为对约定优于配置、依赖自动推导、错误前置拦截等最佳实践的原生支持。结合IntelliJ IDEA的成熟Java开发环境,Qoder实现了从需求描述到模块交付的端到端加速,尤其适用于CRUD密集型业务开发、外包交 阅读详情

更多内容欢迎访问我的个人 Java 站点:开坑组-Java站

前言

之前的5个篇章基本上能完成一个登录模块,这篇我们介绍下如何在 body 中使用 JSON 来传参调用登录接口,后续还会再补充下登出逻辑。

1. 添加工具类

工具类中添加用于从 HttpServletRequest 中获取参数的方法

package com.example.security.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Slf4j
public class CommonUtil {

    private static final String PARSED_BODY_KEY = "PARSED_BODY";

    /**
     * 获取请求中的所有参数
     */
    public static final Map<String, Object> getBodyParametersFromRequest(HttpServletRequest request) {
        Map<String, Object> map = null;

        if (request != null) {
            // 优先从 request attribute 中读取参数
            map = (Map<String, Object>) request.getAttribute(PARSED_BODY_KEY);

            // 若从 request attribute 没有读取到参数则从 request 中读取,这样做是因为 request 的流只能读取一次
            if (map == null) {
                map = readParamsFromRequest(request);
                // 读取完以后存入 request attribute
                request.setAttribute(PARSED_BODY_KEY, map);
            }
        }

        if (map == null) {
            map = new HashMap<>(0);
        }

        return map;
    }

    /**
     * 获取请求中的指定字符串参数
     */
    public static final String getStringBodyParameterFromRequest(HttpServletRequest request, String key) {
        String result = Strings.EMPTY;
        Map<String, Object> map = getBodyParametersFromRequest(request);

        if (map.get(key) != null) {
            result = map.get(key).toString();
        }

        return result;
    }

    /**
     * 从请求中读取参数,转为 Map
     */
    private static Map<String, Object> readParamsFromRequest(HttpServletRequest request) {
        Map<String, Object> map = null;

        try {
            // 从 request 中读取 Body 数据
            ServletInputStream inputStream = request.getInputStream();
            StringBuilder content = new StringBuilder();
            byte[] b = new byte[1024];
            int lens;
            while ((lens = inputStream.read(b)) > 0) {
                content.append(new String(b, 0, lens));
            }

            // 将字符串转换为 Map 集合
            ObjectMapper mapper = new ObjectMapper();
            map = mapper.readValue(content.toString(), Map.class);
        } catch (Exception ex) {
            log.error("Error occurred while read params from request");
        }

        return map;
    }
}

2. 添加自定义用户名密码认证过滤器

继承 UsernamePasswordAuthenticationFilter 类,并复写 attemptAuthentication 方法,主动读取 body 中的参数。

package com.example.security.filter;

import com.example.security.utils.CommonUtil;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter {

    private static final String APPLICATION_JSON_UTF8_VALUE_WITH_SPACE = "application/json; charset=UTF-8";
    private static final String USERNAME = "username";
    private static final String PASSWORD = "password";

    @Override
    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
        // 通过 ContentType 判断是否是 JSON 登录
        String contentType = request.getContentType();
        if (MediaType.APPLICATION_JSON_UTF8_VALUE.equalsIgnoreCase(contentType) ||
                APPLICATION_JSON_UTF8_VALUE_WITH_SPACE.equalsIgnoreCase(contentType) ||
                MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(contentType)) {

            // 获取 body 参数 Map
            Map<String, String> obj = CommonUtil.getBodyParametersFromRequest(request);
            // 使用用户名密码构建 Token
            UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
                    obj.get(USERNAME), obj.get(PASSWORD));
            setDetails(request, token);

            return this.getAuthenticationManager().authenticate(token);
        } else {
            return super.attemptAuthentication(request, response);
        }
    }
}

3. 修改 SecurityConfig 中的登录配置

package com.example.security.config;

import com.example.security.filter.CustomAuthenticationFilter;
import com.example.security.filter.ValidateCaptchaFilter;
import com.example.security.handler.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.ObjectPostProcessor;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    LoginSuccessHandler successHandler;

    @Autowired
    LoginFailureHandler failureHandler;

    @Autowired
    ValidateCaptchaFilter validateCaptchaFilter;

    @Autowired
    FilterInvocationSecurityMetadataSourceHandler securityMetadataSourceHandler;

    @Autowired
    AccessDecisionHandler accessDecisionHandler;

    @Autowired
    AccessDeniedHandler accessDeniedHandler;

    @Autowired
    AuthenticationEntryPointExceptionHandler entryPointExceptionHandler;

    @Autowired
    LogoutSuccessHandler logoutSuccessHandler;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // 禁用CSRF 开启跨域
        http.cors().and().csrf().disable();

        http.authorizeRequests()
                // 通过 withObjectPostProcessor 将我们的两个处理器添加进入验证流程
                .withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
                    @Override
                    public <O extends FilterSecurityInterceptor> O postProcess(O o) {
                        // 决策管理器
                        o.setAccessDecisionManager(accessDecisionHandler);
                        // 权限数据源
                        o.setSecurityMetadataSource(securityMetadataSourceHandler);
                        return o;
                    }
                })
                // 配置验证码接口不需要校验
                .antMatchers("/login/captcha").permitAll()
                // 其他请求都需要校验
                .anyRequest().authenticated()
            .and()
                // 添加异常处理器
                .exceptionHandling()
                .accessDeniedHandler(accessDeniedHandler)
                .authenticationEntryPoint(entryPointExceptionHandler);
//            更换登录配置方式
//            .and()
//                // 登录接口不需要校验
//                .formLogin().permitAll()
//                .successHandler(successHandler)
//                .failureHandler(failureHandler);

        // 在用户名密码校验过滤器之前添加上验证码校验过滤器
        http.addFilterBefore(validateCaptchaFilter, UsernamePasswordAuthenticationFilter.class);
    }

    /**
     * 登录配置,使用自定义的用户名密码验证过滤器
     */
    @Bean
    CustomAuthenticationFilter customAuthenticationFilter() throws Exception {
        CustomAuthenticationFilter filter = new CustomAuthenticationFilter();
        filter.setAuthenticationSuccessHandler(successHandler);
        filter.setAuthenticationFailureHandler(failureHandler);
        // 可自定义登录接口请求路径
        // filter.setFilterProcessesUrl("");
        filter.setAuthenticationManager(authenticationManagerBean());

        return filter;
    }

    /**
     * 使用 Spring Security 自带的密码加密器
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}

4. 修改验证码读取方式为 json body 读取

package com.example.security.filter;

import com.example.security.exception.ValidateCaptchaException;
import com.example.security.model.Captcha;
import com.example.security.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Component
public class ValidateCaptchaFilter extends OncePerRequestFilter {

    @Autowired
    private AuthenticationFailureHandler authenticationFailureHandler;

    @Autowired
    private HttpSession session;

    /**
     * 静态字段可以添加至单独的静态字段文件中
     */
    private static final String LOGIN_PATH = "/login";
    private static final String POST_METHOD = "post";
    private static final String CAPTCHA_IS_EMPTY = "Captcha is empty";
    private static final String CAPTCHA_NOT_EXISTED = "Captcha not existed";
    private static final String CAPTCHA_IS_EXPIRED = "Captcha is expired";
    private static final String CAPTCHA_NOT_MATCHED = "Captcha not matched";
    private static final String CAPTCHA = "captcha";
    private static final String SESSION_KEY_CAPTCHA = "SESSION_KEY_CAPTCHA";

    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                                    FilterChain filterChain) throws ServletException, IOException {

        // 判断是否为请求登录接口,校验验证码
        if (LOGIN_PATH.equalsIgnoreCase(httpServletRequest.getRequestURI())
                && POST_METHOD.equalsIgnoreCase(httpServletRequest.getMethod())) {
            try {
                validateCode(new ServletWebRequest(httpServletRequest));
            } catch (ValidateCaptchaException e) {
                authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, e);
                return;
            }
        }
        filterChain.doFilter(httpServletRequest, httpServletResponse);
    }
    private void validateCode(ServletWebRequest servletWebRequest) {
        Captcha codeInSession = (Captcha) session.getAttribute(SESSION_KEY_CAPTCHA);
        // 修改为从 body 中的 JSON 读取出验证码
        String codeInRequest = CommonUtil.getStringBodyParameterFromRequest(servletWebRequest.getRequest(), CAPTCHA);

        if (StringUtils.isEmpty(codeInRequest)) {
            throw new ValidateCaptchaException(CAPTCHA_IS_EMPTY);
        }
        if (codeInSession == null) {
            throw new ValidateCaptchaException(CAPTCHA_NOT_EXISTED);
        }
        if (codeInSession.isExpire()) {
            session.removeAttribute(SESSION_KEY_CAPTCHA);
            throw new ValidateCaptchaException(CAPTCHA_IS_EXPIRED);
        }
        if (!codeInSession.getCode().equalsIgnoreCase(codeInRequest)) {
            throw new ValidateCaptchaException(CAPTCHA_NOT_MATCHED);
        }

        session.removeAttribute(SESSION_KEY_CAPTCHA);
    }
}

5. 添加登出处理成功处理器

package com.example.security.handler;

import org.springframework.security.core.Authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class LogoutSuccessHandler implements org.springframework.security.web.authentication.logout.LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                                Authentication authentication) throws IOException {

        httpServletResponse.getWriter().write("Logout success");
    }
}

6. 在 SecurityConfig 中添加登出配置

package com.example.security.config;

import com.example.security.filter.CustomAuthenticationFilter;
import com.example.security.filter.ValidateCaptchaFilter;
import com.example.security.handler.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.ObjectPostProcessor;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    LoginSuccessHandler successHandler;

    @Autowired
    LoginFailureHandler failureHandler;

    @Autowired
    ValidateCaptchaFilter validateCaptchaFilter;

    @Autowired
    FilterInvocationSecurityMetadataSourceHandler securityMetadataSourceHandler;

    @Autowired
    AccessDecisionHandler accessDecisionHandler;

    @Autowired
    AccessDeniedHandler accessDeniedHandler;

    @Autowired
    AuthenticationEntryPointExceptionHandler entryPointExceptionHandler;

    @Autowired
    LogoutSuccessHandler logoutSuccessHandler;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // 禁用CSRF 开启跨域
        http.cors().and().csrf().disable();

        http.authorizeRequests()
                // 通过 withObjectPostProcessor 将我们的两个处理器添加进入验证流程
                .withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
                    @Override
                    public <O extends FilterSecurityInterceptor> O postProcess(O o) {
                        // 决策管理器
                        o.setAccessDecisionManager(accessDecisionHandler);
                        // 权限数据源
                        o.setSecurityMetadataSource(securityMetadataSourceHandler);
                        return o;
                    }
                })
                // 配置验证码接口不需要校验
                .antMatchers("/login/captcha").permitAll()
                // 其他请求都需要校验
                .anyRequest().authenticated()
            .and()
                // 添加异常处理器
                .exceptionHandling()
                .accessDeniedHandler(accessDeniedHandler)
                .authenticationEntryPoint(entryPointExceptionHandler)
            .and()
                // 登出配置
                .logout()
                .permitAll()
                // 可以配置不同的登出接口请求地址
                // .logoutUrl()
                .logoutSuccessHandler(logoutSuccessHandler)
                // 登出之后删除cookie
                .deleteCookies("JSESSIONID");

        // 在用户名密码校验过滤器之前添加上验证码校验过滤器
        http.addFilterBefore(validateCaptchaFilter, UsernamePasswordAuthenticationFilter.class);
    }

    /**
     * 登录配置,使用自定义的用户名密码验证过滤器
     */
    @Bean
    CustomAuthenticationFilter customAuthenticationFilter() throws Exception {
        CustomAuthenticationFilter filter = new CustomAuthenticationFilter();
        filter.setAuthenticationSuccessHandler(successHandler);
        filter.setAuthenticationFailureHandler(failureHandler);
        // 可自定义登录接口请求路径
        // filter.setFilterProcessesUrl("");
        filter.setAuthenticationManager(authenticationManagerBean());

        return filter;
    }

    /**
     * 使用 Spring Security 自带的密码加密器
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}

7. 测试

  • 使用 JSON body 传参登录
    使用 JSON body 传参登录

  • 登出
    登出

总结

使用 body JSON 传参的主要点在于使用自定义的用户登录认证过滤器,在自定义逻辑里面可以读取 request 中的 body 参数,处理起来也很简单。

需要注意的点是因为我们使用了验证码,需要同时将验证码也改为从 body JSON 中获取。这个时候就需要读取两次 request 中的参数,但是 request 中的可读流只能读取一次,不能将读取的位置回归起点,所以我们需要将参数存储在 request attributes 中,以便于可以多次读取参数。

登出逻辑的处理与登录逻辑比较相似,需要注意的是要记得在登出的时候清理掉 Cookies 中的 session id。

Spring Boot+MyBatis+Thymeleaf网上购物系统课程设计实战 Java Web开发中,基于Spring Boot的轻量级Web应用是高校课程设计与初学者工程实践的核心载体。其本质是整合MVC分层架构、关系型数据库交互与服务端模板渲染的技术闭环。Spring Boot简化了传统SSM配置复杂度,MyBatis提供面向POJO的SQL映射能力,Thymeleaf则实现安全可控的服务端HTML渲染,三者协同构成可调试、可演示、可答辩的最小可行工程(MVP)。该技术组合广泛应用于教学实训、毕业设计及企业内部管理系统原型开发,尤其适合JDK 1.8/MySQL 8.0等高校实验 阅读详情

相关推荐

Linux基础——“C语言高级编程” C语言中的细节你真的知道吗?

文章目录GCC简介 GCC简介 gcc 所支持后缀名解释 .c c原始程序 .C / .cc /.cxx C++原始程

weixin_44278698的博客 2513

接口测试--Postman

1、Get请求      1)获取学生信息           对接口http://118.24.3.40/api/user/stu_info进行接口测试           方法1:直接通过浏览器对接口进行调用          ①没有填写任何入参,直接访问接口                  会报错,提示有必填参数没有填写。       ②在接口后面加入参数?stu_name=柯南,查询姓名...

XXDYxxdy的博客 473

第四章 汇川技术InoProShop入门之串口自由协议解读

摘要: 串口自由协议是工业自动化中针对特定需求设计的自定义通信协议,具有高度灵活性和针对性,适用于小型设备、实时控制等场景。其核心包括自定义帧结构(起始符、地址码、数据区、校验位等)和通信规则(波特率、交互机制)。相比标准协议,自由协议效率更高但兼容性弱,设计时需注重可靠性、效率和可扩展性,适用于定制化或高实时性需求,如传感器数据采集或老旧设备改造。典型应用需平衡精简帧结构与抗干扰能力,同时预留扩展空间。

zyfucking2010的博客 2220

关于HttpPost调用接口以body形式传递参数的方案

#HttpPost调用接口以body形式传参,可解决中文乱码问题。

sinat_33316512的博客 5230

Quartus的Signal Tap II的使用技巧

Signal Tap II全称Signal Tap II Logic Analyzer,是第二代系统级调试工具,它集成在Quartus II软件中,可以捕获和显示实时信号,是一款功能强大、极具实用性的FPGA片上调试工具软件。传统的FPGA板级调试是由外接的逻辑分析仪连接到FPGA的控制引脚,将内部引号引出至引脚I/O上,接着进行板级调试。

qq_37624854的博客 5904

PySpark 本地开发环境搭建与实践

本文详细介绍了 PySpark 本地开发环境的搭建过程,包括 JDK、Hadoop、Anaconda、PySpark 的安装以及 Pycharm 工程的创建。同时,深入讲解了代码编写、本地开发案例(如 WordCount、处理特殊分隔符、读取 hdfs 数据、获取外部变量)、Spark 程序的监控和 local 模式下结果文件数量问题等内容。通过掌握这些知识和技能,读者可以在 Windows 本地环境中高效地进行 PySpark 开发,处理大规模数据,解决实际业务中的数据分析和处理问题。

天冬忘忧的博客 3016

关于使SpringSecurity登录参数使用requestBody后引发的一系列问题及解决

使用SpringSecurity前后端分离,使登录参数支持RequestBody后,单点登录功能失效,最终通过调试源码找到解决办法

c_z_z的博客 1408

基于 YOLOv26 的 PCB 板缺陷检测:工业级视觉实战

本文提出了一种基于YOLOv26的PCB板缺陷检测系统,通过深度学习技术实现对PCB板缺陷的自动化检测。系统能够识别短路、开路、焊点不良等8种常见缺陷,具有高精度、多类别分类和实时推理等优势。文章详细介绍了系统架构,包括数据采集、预处理、YOLOv26模型检测和后处理模块。在代码实现部分,给出了环境配置、数据预处理与增强的具体方法,使用Albumentations库进行图像增强处理。该系统为电子制造业提供了高效、准确的PCB质量检测解决方案,显著提升了检测效率和准确性。

一键难忘的博客 340

SpringBoot如何配置获取request中body的json格式参数

背景介绍:最近开发一个http的插件应用对接别人的报警推送平台 平台方给的json报文并不全,需要我们自己做个模拟接口来确定报文格式,也就是需要拿到他们传来的报警参数。注意事项:Param是测试的实体类,怎么写它的属性都行,嫌麻烦的话就直接用我的吧。1.定义增强类,继承HttpServletRequestWrapper。借鉴的很多大佬的博客资料 终于确定了最主流的一套方法:包装类+过滤器。4.创建模拟接口测试。

qq_45472669的博客 4552

改进的U-Net在视网膜血管分割上的应用

为了提高算法在血管边界的分割能力,在编码部分采用全局卷积网络(GCN)和边界细化(BR)替换传统的卷积层;在跳跃连接部分引入改进的位置注意模块(PA)和通道注意模块(CA),目的是增加血管与背景之间的对比度,使网络更好地将血管与背景分割开;此外,为了提高网络的性能,在编码部分的最后一层使用密集卷积网络解决网络过拟合问题,同时为了在一定程度上解决梯度爆炸、梯度消失的问题,在解码部分的每一层使用卷积长短记忆网络提升网络获取特征信息的能力。替换传统的卷积操作来解决血管边界非血管像素误分为血管的问题。

weixin_70923796的博客 785

Agentic AI应用架构师如何提升AI应用的灵活性

可扩展性(Scalability):快速添加新功能或扩展任务范围(如Agent从“客服”扩展到“供应链管理”);可修改性(Modifiability):调整Agent的决策逻辑或动作策略,无需重构整个系统;鲁棒性(Robustness):在环境异常或数据噪声下保持性能稳定;自适应(Self-Adaptation):自主学习新场景,无需人工干预。状态空间(S):Agent能感知的所有内部/外部状态(如用户需求、环境数据);动作空间(A):Agent能执行的所有动作(如调用工具、发送消息);

项目管理的博客 607

SpringBoot 配置获取request中body的json格式参数

获取GET、POST请求中的参数 获取POST请求中的JSON格式的参数

Duktig的博客 8853

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Spring boot 使用restful风格的spring security login

Spring boot 使用restful风格的spring security login第一步,获取基本springboot项目 从 spring官网获取security+session+redis依赖的springboot项目 安装配置redis,修改配置文件,启动项目,拿到登录密码,用户名为user. 根据官方文档,配置demo项目,理解spring security的机制 第

iverson2010112228的专栏 6752

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Spring boot + spring security 实现 Rest 登录 ( json )

第一步,获取基本springboot项目 从 spring官网获取security+session+redis依赖的springboot项目 安装配置redis,修改配置文件,启动项目,拿到登录密码,用户名为user. 根据官方文档,配置demo项目,理解spring security的机制 第二步,添加自己的登录验证方式 添加session策略,让权限验证从session里获取token,而不是...

李昊轩的博客 2327

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Spring security 自定义过滤器实现Json参数传递-并兼容表单参数

依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <group.

hu10131013的博客 10万+

Java八股文面试之框架篇(Spring、SpringMVC、Mybatis、Spring Security)

Java八股文面试之框架篇(Spring、SpringMVC、Mybatis)

y516369的博客 1305

Spring Boot法律援助管理系统实战:从零部署到功能验证

在Java企业级应用开发中,Spring Boot凭借其约定大于配置的理念,极大地简化了基于Spring框架的后端服务搭建流程。其核心原理是通过自动配置和起步依赖,快速整合数据访问、安全、Web等模块,为开发者提供开箱即用的生产力工具。这一技术价值在于能够高效构建稳定、可扩展的RESTful API服务,广泛应用于各类后台管理系统。具体到应用场景,例如在需要处理复杂业务流程和大量数据的管理系统中,Spring Boot能够快速实现用户认证、数据CRUD、状态流转等核心功能。本文聚焦于一个典型的实战项目——法

axfcjwkbi259888707的博客 385

Spring Boot拦截器获取请求体:解决InputStream只读一次的最佳实践

在Web开发中,HTTP请求体(request body)只能被读取一次,这是Servlet InputStream的天然限制。理解这一原理,是解决Spring Boot拦截器无法正确获取JSON参数问题的关键。通过Filter与自定义RequestWrapper,可以在请求进入Controller之前缓存请求体,实现流的可重复读取,从而支持日志审计、签名校验、参数预处理等场景。本文结合ContentCachingRequestWrapper与自定义缓存包装类,梳理了从原理、方案对比到工程落地的最佳实践,帮

weixin_34211761的博客 219

(课程设计)spring boot小说网站系统 毕业设计 附源码 041446

管理员账户的基本信息管理。主要提供管理员账户的基本信息录入、删除、维护和查询等功能,包括: 管理员录入管理员账户基本信息; 管理员更新、增加及删除管理员账户基本信息; 用户根据管理员账户 ID 查询基本信息; 系统管理员更改个人密码; 留言的基本信息管理。主要提供留言的基本信息录入、修改和查询功能,包括: 用户录入留言基本信息; 管理员更新、增加及删除留言基本信息; 评论的基本信息管理。主要提供评论的基本信息录入、修改和查询功能,包括: 用户录入评论基本信息; 管理员更新、增加及删除评论基本信息; ..

ID3461074420的博客 5501

Spring Boot校园考研论坛APP毕业设计全流程:从技术选型到部署避坑

在Java服务端开发中,Spring Boot凭借自动配置与起步依赖大幅简化了企业级应用搭建流程,成为快速构建业务系统的首选框架。论坛类应用作为典型的信息发布与社区互动场景,其核心在于用户认证、内容管理、数据存储与前后端交互。基于Spring Boot搭建后台接口,结合MySQL持久化数据,并采用uni-app实现跨端移动端应用,可形成一套完整的全栈实践闭环。该技术路线不仅覆盖RESTful API设计、JWT鉴权、拦截器权限控制等关键工程能力,还能通过实践理解分页查询、点赞统计等常见业务逻辑的实现方案。这

weixin_34013044的博客 278

Spring Boot + Vue3全栈实战:从零搭建美食网站项目保姆级教程

前后端分离架构是现代Web开发的主流范式,其核心原理是将前端用户界面与后端业务逻辑、数据访问层解耦,通过定义清晰的API接口进行通信。这种架构模式的技术价值在于实现了关注点分离,允许前后端团队独立开发、测试和部署,提升了开发效率和系统可维护性。在实际应用场景中,无论是电商平台、内容管理系统还是社交应用,都广泛采用此架构来构建高性能、可扩展的Web应用。本文聚焦于一个具体的美食网站项目,深入剖析如何使用Spring Boot构建RESTful API后端,并结合Vue3与Element Plus开发动态前端界

340

基于Spring Boot和Vue 3的AI宠物领养管理系统全栈项目实战

全栈开发是连接前后端技术的关键实践。在构建具备用户认证、业务流转和AI能力的Web应用时,需要理解RESTful API设计、数据库建模、状态管理、前后端联调等核心环节。本文以一个AI宠物领养管理系统为例,使用Spring Boot提供后端接口,Vue 3构建管理页面,MySQL持久化数据,并通过大模型接口实现智能推荐与问答。从数据库表设计、JWT登录认证、领养申请状态机到AI助手封装,完整展示一个可运行的Demo。文中还涵盖接口自测、常见报错排查以及生产部署建议,帮助开发者迁移模块设计思路到其他管理系统。

weixin_34220179的博客 445

Vue+Spring Boot全栈实战:青年大学习成果记录管理系统开发

前后端分离架构已成为现代Web应用开发的主流范式,Vue与Spring Boot的组合凭借各自生态优势,被广泛用于各类管理系统的快速构建。本文从业务状态机设计出发,围绕学习记录、视频进度上报、审核流程、积分统计等核心模块,系统讲解从数据库建模、接口设计到前端页面渲染、数据可视化的完整实现路径。通过JWT+Redis保障身份认证安全,借助MyBatis-Plus简化数据持久层操作,结合ECharts生成学院完成率、个人排行等报表,并覆盖M3U8视频播放与跨域部署等工程实践。这套方案适用于高校学习管理、课程设计

weixin_34364071的博客 419

Vue+Spring Boot+MySQL全栈交互诊断框架

在现代Web开发中,前后端与数据库的交互并非简单API调用,而是涉及数据语义、通信契约、状态边界与错误归因的系统性工程。理解HTTP请求生命周期、RESTful接口设计原则及跨层数据一致性机制,是保障系统稳定性的技术基础。Vue提供响应式状态管理与可视化调试能力,Spring Boot通过自动配置与Actuator实现服务可观测性,MySQL则以ACID特性和严谨约束承担业务规则仲裁职责。本文聚焦于三者协同中的典型断点——跨域配置、日期时区、中文编码、分页稳定性与全链路调试路径,构建一套可落地的交互诊断框架

weixin_33951761的博客 268

(附源码)spring boot图书管理系统-毕业设计 课程设计 160934

系统开发是采用java语言,基于MVVM模式进行开发,采取MySQL作为后台数据的主要存储单元,采用Springboot框架实现了本系统的全部功能。图书管理系统解决了传统管理方式所带来的人力、物力和时间上的虚耗和交流深度的限定,这让交流的过程更快捷、准确、便利,同时完成图书管理系统的基本功能:新闻数据管理、用户注册管理、图书管理、图书分类管理、入库管理、出库管理。

Q_3461074420的博客 1741
上一篇: leetcode 做题记录 - 767.重构字符串
下一篇: leetcode 做题记录 - 204.计数质数
老菜鸟zzzzz
博客等级 码龄9年 1粉丝 16原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值