springboot跨域Restful和返回json串的controller类模板

请求路径参考:

localhost:80/test/test?str=ok

@RestController
@RequestMapping("test")
@CrossOrigin // 解决跨域问题
public class ControllerTest {
    @RequestMapping("test")
    public Animal test(@RequestParam("str") String str){
        System.out.println(str);
        Animal animal = new Animal();
        animal.setId("wifi");
        animal.setName("aoer");
        return animal;
    }
}

你可能感兴趣的:(springboot跨域Restful和返回json串的controller类模板)