Spring Rest-API - 403 forbidden error response

前端 未结 1 915
我在风中等你
我在风中等你 2021-01-15 10:01

I,m new to spring, I,m writing REST API. I/\'m getting 403 forbidden error for delete, put. Following is the sample I\'m working on.

@RequestMapping(value =          


        
相关标签:
1条回答
  • 2021-01-15 10:20

    Just add these filter line in web.xml.

    <filter>
            <filter-name>CorsFilter</filter-name>
            <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
            <init-param>
                <param-name>cors.allowed.origins</param-name>
                <param-value>*</param-value>
            </init-param>
            <init-param>
                <param-name>cors.allowed.headers</param-name>
                <param-value>Content-Type,X-Requested-With,accept,authorization,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
            </init-param>
            <init-param>
            <param-name>cors.allowed.methods</param-name>
            <param-value>GET, POST, PUT, DELETE, OPTIONS, HEAD</param-value>
        </init-param>
        </filter>
    
    0 讨论(0)
提交回复
热议问题