【学习笔记】使用springboot开发get方法接口-cookie相关

本文记录了使用SpringBoot开发GET方法接口并处理Cookie的步骤。首先,通过@ComponentScan注解设置扫描路径,然后创建MyGetMethod方法实现接口。运行应用后,成功获取并设置了Cookie信息。接着,要求客户端携带Cookie访问,通过修改代码并使用JMeter进行验证,确保功能正常。
摘要由CSDN通过智能技术生成
  1. 创建一个application的类来作为入口:此处注意注解@ComponentScan的作用
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication //把类托管到spring当中,请srping帮忙组织一下
@ComponentScan("com.gracie.server") // 需要扫描那些组件, 注意路径的问题
public class Application {

    //入口类,用来运行application这个类,基本上属于固定写法
    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
    }
}

  1. 创建方一个路径,把此路径告知@ComponentScan,让它可以去扫描
    在这里插入图片描述
  2. 创建方法: MyGetMethod:
package com.gracie.server;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值