• 大小: 45.64MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-16
  • 语言: 其他
  • 标签: Springboot  ajax  

资源简介

使用Springboot进行简单的增删改查,用ajax让前后端的数据进行交流。踩过很多坑,才弄成的。

资源截图

代码片段和文件信息

package com.am;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlbasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
public class ShixunApplication {

    public static void main(String[] args) {
        SpringApplication.run(ShixunApplication.class args);
    }
    private CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin(“*“);
        corsConfiguration.addAllowedHeader(“*“);
        corsConfiguration.addAllowedMethod(“*“);
        return corsConfiguration;
    }

    /**
     * 跨域过滤器
     *
     * @return
     */
    @Bean
    public CorsFilter corsFilter() {
        UrlbasedCorsConfigurationSource source = new UrlbasedCorsConfigurationSource();
        source.registerCorsConfiguration(“/**“ buildConfig()); // 4
        return new CorsFilter(source);
    }

    @Configuration
    public class CrossDomain extends WebMvcConfigurerAdapter {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping(“/**“).allowedOrigins(“*“)
                    .allowedMethods(“GET“ “HEAD“ “POST““PUT“ “DELETE“ “OPTIONS“)
                    .allowCredentials(false).maxAge(3600);
        }
    }
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         268  2018-06-27 12:47  shixun\.gitignore
     目录           0  2018-06-30 11:45  shixun\.idea\
     目录           0  2018-06-28 17:55  shixun\.idea\artifacts\
     文件         321  2018-06-27 12:48  shixun\.idea\artifacts\ngqualitypf_war.xml
     文件         706  2018-06-27 12:48  shixun\.idea\artifacts\ngqualitypf_war_exploded.xml
     文件         349  2018-06-27 12:48  shixun\.idea\artifacts\ngqualitypfcontrol_war.xml
     文件         755  2018-06-27 12:48  shixun\.idea\artifacts\ngqualitypfcontrol_war_exploded.xml
     文件         337  2018-06-27 12:48  shixun\.idea\artifacts\ngqualitypfcore_war.xml
     文件       15383  2018-06-28 17:55  shixun\.idea\artifacts\ngqualitypfcore_war_exploded.xml
     文件         984  2018-06-28 17:55  shixun\.idea\compiler.xml
     文件         487  2018-06-27 12:49  shixun\.idea\encodings.xml
     目录           0  2018-06-28 17:55  shixun\.idea\libraries\
     文件         462  2018-06-27 12:56  shixun\.idea\libraries\Maven__antlr_antlr_2_7_7.xml
     文件         514  2018-06-28 17:55  shixun\.idea\libraries\Maven__aopalliance_aopalliance_1_0.xml
     文件         448  2018-06-28 17:55  shixun\.idea\libraries\Maven__cglib_cglib_3_1.xml
     文件         568  2018-06-27 12:56  shixun\.idea\libraries\Maven__ch_qos_logback_logback_classic_1_2_3.xml
     文件         547  2018-06-27 12:56  shixun\.idea\libraries\Maven__ch_qos_logback_logback_core_1_2_3.xml
     文件         489  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_101tec_zkclient_0_3.xml
     文件         459  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_ai_common_1_9.xml
     文件         493  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_alibaba_druid_1_0_16.xml
     文件         486  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_alibaba_dubbo_2_5_4.xml
     文件         592  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_alibaba_rocketmq_rocketmq_client_3_5_9.xml
     文件         592  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_amazonaws_aws_java_sdk_core_1_10_69.xml
     文件         585  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_amazonaws_aws_java_sdk_kms_1_10_69.xml
     文件         578  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_amazonaws_aws_java_sdk_s3_1_10_69.xml
     文件         499  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_carrotsearch_hppc_0_7_1.xml
     文件         599  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_cmos_cmos_cache_1_3_3_SNAPSHOT.xml
     文件         588  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_cmos_cmos_cfg_0_0_5_SNAPSHOT.xml
     文件         606  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_cmos_cmos_core_0_6_7_4_SNAPSHOT.xml
     文件         627  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_cmos_cmos_exception_1_0_0_SNAPSHOT.xml
     文件         609  2018-06-28 17:55  shixun\.idea\libraries\Maven__com_cmos_cmos_logger_1_2_0_SNAPSHOT.xml
............此处省略1578个文件信息

评论

共有 条评论