游侠的博客 游侠的博客
首页
  • 论文笔记
  • 一些小知识点

    • pytorch、numpy、pandas函数简易解释
  • 《深度学习500问》
开发
技术
更多
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Ranger

一名在校研究生
首页
  • 论文笔记
  • 一些小知识点

    • pytorch、numpy、pandas函数简易解释
  • 《深度学习500问》
开发
技术
更多
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Vue

  • SpringBoot2

    • 各种小知识
      • @ResponseBody作用
      • @RestController
      • @RequestMapping注解加在Controller类上
      • @TableName注解
      • BaseMapper继承
      • MapperScan注解
    • 一、SpringBoot基础入门
    • 二、SpringBoot的底层注解
    • 三、SpringBoot的自动配置
    • 四、SpringBoot的最佳实践
    • 五、SpringBoot的配置文件
    • 六、SpringBoot的Web场景
    • 七、SpringBoot的请求处理(源码分析)
  • JavaWeb

  • SSM

  • SpringBoot3

  • 技术
  • SpringBoot2
yangzhixuan
2023-03-24
目录

各种小知识

# @ResponseBody作用

在Controller方法前面加上该注解之后,不会再走视图解析器,即不进行请求转发之类的操作,而是直接返回数据,在写数据接口的时候这个注解基本上必加

# @RestController

这个注解作用于Controller类,加上之后,这个类下的方法都会使用@ResponseBody注解

# @RequestMapping注解加在Controller类上

Controller类加上该注解后,该类方法上的RequestMapping注解路径前面都会加上该路径

@RestController
@RequestMapping(("/secrettext"))
public class SecretTextController {
    @Autowired
    SecretTextService secretTextService;

    @RequestMapping("/showtext")
    public String showText() {
        
    }
}
1
2
3
4
5
6
7
8
9
10
11

# @TableName注解

使用mybatis-plus时,在pojo类上加上该注解能在mapper映射数据库表时指定表名

@TableName("secret_text")
public class SecretText {
    // 文本内容
    String content;
    // 提取码
    String extractCode;

}
1
2
3
4
5
6
7
8

# BaseMapper继承

在使用mybatis-plus时,让mapper接口继承该类能实现很多常用的CRUD方法

public interface SecretTextMapper extends BaseMapper<SecretText> {
    List<SecretText> getSecretTextList();
}
1
2
3

# MapperScan注解

加在启动类上,查找包下的所有mapper类,在编译之后生成相应的实现类

@SpringBootApplication
@MapperScan(basePackages = {"com.ouyang.easypaste.mapper"})
public class EasypasteApplication {
    public static void main(String[] args) {
        SpringApplication.run(EasypasteApplication.class, args);
    }
}
1
2
3
4
5
6
7
编辑 (opens new window)
上次更新: 2024/05/30, 07:49:34
element-plus不使用index作为path在激活导航时进行默认的路由跳转
一、SpringBoot基础入门

← element-plus不使用index作为path在激活导航时进行默认的路由跳转 一、SpringBoot基础入门→

最近更新
01
tensor比较大小函数
05-30
02
Large Language Models can Deliver Accurate and Interpretable Time Series Anomaly Detection
05-27
03
半监督学习经典方法 Π-model、Mean Teacher
04-10
更多文章>
Theme by Vdoing | Copyright © 2023-2024 Ranger | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式