caolinxuan 2 months ago
parent
commit
6b1153c3ac

+ 18 - 0
src/main/java/com/zhentao/shiro/config/CorsConfig.java

@@ -0,0 +1,18 @@
+package com.zhentao.shiro.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 CorsConfig implements WebMvcConfigurer {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+            .allowedOrigins("*")
+            .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
+            .maxAge(3600);
+    }
+
+}

+ 7 - 0
src/main/java/com/zhentao/test01.java

@@ -0,0 +1,7 @@
+package com.zhentao;
+
+public class test01 {
+    public static void main(String[] args) {
+        System.out.println("hello world");
+    }
+}