如何使用 Spring MVC 处理 HTTP 选项? [英] How to handle HTTP OPTIONS with Spring MVC?

查看:24
本文介绍了如何使用 Spring MVC 处理 HTTP 选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的控制器使用 Spring MVC 拦截 OPTIONS 请求,但它被 DispatcherServlet 捕获.我该如何管理?

I'd like to intercept the OPTIONS request with my controller using Spring MVC, but it is catched by the DispatcherServlet. How can I manage that?

推荐答案

@RequestMapping(value="/youroptions", method=RequestMethod.OPTIONS)
public View getOptions() {

}

您应该通过将其 dispatchOptionsRequest 设置为 true

You should configure the dispatcherServlet by setting its dispatchOptionsRequest to true

这篇关于如何使用 Spring MVC 处理 HTTP 选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆