我正在使用 @RestController 提供 REST 服务。但我需要在响应头中设置 Access-Control-Allow-Origin。我该怎么做?
我的休息控制器:
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class restController {
@RequestMapping("/some")
public Response some(@RequestParam(value="body") String user) {
return new Response(user);
}
}
我的回复:
public class Response {
long id;
String user;
public Response(String user) {
this.id = 7;
this.user = user;
}
}
@RestController 工作得很好,但如何修改它或设置 Access-Control-Allow-Origin 的响应?
慕勒3428872
相关分类