在wildfly上使用spring-security登录时,我收到此错误页面:
{"timestamp":1464679377206,"status":999,"error":"None","message":"No message available"}
刷新后,它会在我的自定义错误页面上重定向。然后,如果我清除错误链接(如http://myapp/error - > http://myapp)应用程序正常工作。当我用spring-boot(不是wildfly)启动这个应用程序时,没有这样的问题。
申请类
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<Application> applicationClass = Application.class;
}
Thymeleaf登录表单
<div sec:authorize="isAnonymous()" id="anonymous-navbar" class="navbar-collapse collapse">
<form th:action="@{/login}" method="post" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" name="username" placeholder="User" class="form-control" />
</div>
<div class="form-group">
<input type="password" name="password" placeholder="Password" class="form-control" />
</div>
<button type="submit" class="btn btn-success" value="login">Log in</button>
</form>
安全配置
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
UserService userService;
@Autowired
@Qualifier("userServiceImpl")
UserDetailsService userDetailsService;
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home", "/signup", "/add_person").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/images/**");
}
}
调试Spring类DefaultErrorAttributes之后,发送消息我得到了这个错误
FirewalledRequest[ HttpServletRequestImpl [ GET /PersonalFinance/error ]]
我看过野蝇原木,并没有找到任何有用的东西。
有一些相同的问题:
但这些答案尚未解决问题
答案 0 :(得分:1)
发生错误导致带有图像的文件夹未包含在项目中,但是在spring-security配置中指定。因此,春天没有找到这条路并且犯了错误。