405不允许用于POST的方法

405不允许用于POST的方法,第1张

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



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5621664.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存