java cors delete_java – 在Rest Controller中删除方法Cors问题

我的项目中有一些Rest端点,我从另一台服务器的客户端应用程序调用.我已经使用@CrossOrigin注释成功禁用了Cors,除了在Chrome上抛出以下错误的Delete方法之外,所有方法都正常工作:

XMLHttpRequest无法加载http:// localhost:8856 / robotpart / 1291542214 /兼容性.对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头.因此,不允许来源“http://127.0.0.1:8888”访问.响应具有HTTP状态代码403.

这是我的控制器:

@CrossOrigin(origins = "*")

@ExposesResourceFor(RobotPart.class)

public class RobotPartController {

//All endpoints are working except the Delete Mapping

@GetMapping("/robotpart")

public ResponseEntity> listAllParts() {

//..

}

@GetMapping("/robotpart/{id}")

public ResponseEntity getById(@PathVariable Integer id) {

//..

}

@GetMapping("/robotpart/{id}/compatibilities")

public ResponseEntity> getRobotCompatibilities(@PathVariable Integer id,

//..

}

@PostMapping("/robotpart")

public ResponseEntity getById(@RequestBody @Valid RobotPart newRobot) {

//..

@PutMapping("/robotpart/{id}")

public ResponseEntity modify(@PathVariable Integer id, @Valid @RequestBody RobotPart newRobot) {

//...

}

@DeleteMapping("/robotpart/{id}")

public ResponseEntity deleteById(@PathVariable Integer id) {

//...

}

}

有什么办法吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值