您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

405不允许用于POST的方法

405不允许用于POST的方法

这应该很容易。

如果启用了CSRF,则不允许POST和PUT请求,认情况下,spring boot会启用这些请求。

只需将其添加到您的配置代码中:

.csrf().disable()

那是 :

http.
.csrf().disable().
authorizeRequests()
        .antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')")
        .and()
          .formLogin().loginPage("/login").failureUrl("/login?error")
          .usernameParameter("username").passwordParameter("password")
        .and()
          .logout().logoutSuccessUrl("/login?logout")
        .and()
          .exceptionHandling().accessDeniedPage("/403");

如果需要启用CSRF,请参考docs:

http://docs.spring.io/spring- security/site/docs/4.0.x/reference/htmlsingle/#csrf- configure

其他 2022/1/1 18:18:21 有524人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶