后端:
package com.example.mybatisplustest.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class Cors implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "PUT", "OPTIONS", "DELETE", "PATCH")
.allowedHeaders("*")
.allowCredentials(true).maxAge(3600);
}
}
package com.example.mybatisplustest.config;
import org.springframework.context.annotation.Configuration;
import javax.servlet.*;
import javax.servlet.an