栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot项目中遇到的问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot项目中遇到的问题

1:首先是用户编辑问题,点击编辑出现弹窗以后,还没有点确定就数据已经修改了:


这里我们这样改:

     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


5:
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/917495.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号