this.form = Object.assign({},row) //解决还没有点确定就已经数据改变的问题
2:怎样使得查询时在前端的返回数据类型中既有data数据也有count总数?:
首先,在后端我们将service中的全部用户查询方法的返回类型写成Hashmap,
这样就可以添加两个对象
3:怎样实现分页?
首先后端,我们写的分页查询方法,先默认给两个传参:
然后前端,使用element插件:
先默认给一个值:
pageNum代表第几页,pageSize代表每一页有几个,pageIndex代表开始展示的数据下标
4:Swagger的配置
springboot在配置Swagger的时候对于版本控制比较严格,springboot2.6之前是使用Swagger2,2.6以后使用Swagger3,我这里说一下怎样配置Swagger3:
依赖:
配置类:io.springfox springfox-boot-starter 3.0.0
package com.example.demo.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@EnableOpenApi
@Configuration
public class SwaggerConfig {
@Bean
public Docket restApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("标准接口")
.apiInfo(apiInfo("Spring Boot中使用Swagger2构建RESTful APIs", "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
//扫描哪个包
.apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo(String title, String version) {
return new ApiInfoBuilder()
.title("项目标题")
.description("更多请关注")
.termsOfServiceUrl("")
.contact(new Contact("", "", ""))
.version(version)
.build();
}
}
.yml配置:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher



