コントローラーメソッド内でスローされた例外は500 internal server errorに変換されると予想していますが、コントローラーメソッド内でどのような例外が発生しても、クライアント側で405 method not allowed例外が発生します。
ノート:
デバッグ時に期待されるメソッドに移動するため、リクエストマッピングに問題はありません。しかし、コントローラーメソッドから例外がスローされると、クライアントで「405メソッドは許可されていません」と表示されます
注 2:
例外をキャッチしてHttpServerErrorException
、適切なエラー コードとメッセージをスローしようとしましたが、何も変わりませんでした。
編集:
私は春のセキュリティを使用していますが、ここに設定があります:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
/*
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/session/**").permitAll()
.antMatchers("/app/**").permitAll()
.antMatchers("/lib/**").permitAll()
.antMatchers("/templates/**").permitAll()
.antMatchers("/dial/**").permitAll()
.antMatchers("/names/**").permitAll()
// .antMatchers("/workflows/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/#/login").permitAll();
http.csrf().disable();
http.exceptionHandling().defaultAuthenticationEntryPointFor(
new UnauthorizedLoginUrlAuthenticationEntryPoint("/login.html"),
new ELRequestMatcher("hasHeader('X-Requested-With','XMLHttpRequest')"));
/* .logout()
.permitAll();*/
}
}