mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-28 15:23:46 +00:00
更新
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package org.itkk.udf.demo.server.core;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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 CorsConfiguration {
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/demo/**")
|
||||
.allowedOrigins("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
@@ -2,11 +2,13 @@ package org.itkk.udf.demo.server.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DemoEntity {
|
||||
private String name;
|
||||
private Date date;
|
||||
|
||||
+8
-8
@@ -1,26 +1,26 @@
|
||||
package org.itkk.udf.demo.server.web;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.itkk.udf.demo.server.domain.DemoEntity;
|
||||
import org.itkk.udf.demo.server.service.DemoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController("demoController")
|
||||
@RequestMapping("demo")
|
||||
@Slf4j
|
||||
public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "t1/{name}")
|
||||
public DemoEntity t1(@PathVariable String name) {
|
||||
demoService.t1();
|
||||
return new DemoEntity(name,new Date());
|
||||
@RequestMapping(method = RequestMethod.POST, path = "t1/{name}")
|
||||
public DemoEntity t1(@RequestBody DemoEntity demoEntity, @PathVariable String name) {
|
||||
log.info("demoEntity:", demoEntity);
|
||||
//demoService.t1();
|
||||
return new DemoEntity(name, new Date());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user