Uploading File Returns 403 Error - Spring MVC

前端 未结 4 1469
鱼传尺愫
鱼传尺愫 2021-01-05 02:25

In my Spring MVC project I am trying to upload a file via a simple form.

HTML Form:

4条回答
  •  鱼传尺愫
    2021-01-05 02:52

    The solution work for me is to disable csrf() in my WebSecurityConfig like :

     @EnableWebSecurity
     @Configuration
    public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.cors().and().csrf().disable();
        }
    }
    

    And now i can simply upload multipart file :)

提交回复
热议问题