Search code examples
javahttpspring-mvchttp-options-method

How to handle HTTP OPTIONS with Spring MVC?


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?


Solution

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

    You should configure the dispatcherServlet by setting its dispatchOptionsRequest to true