Here is my WebAppInitializer:
@Configuration public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[] { AppConfig.class, WebSecurityConfig.class }; } @Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[] { WebConfig.class }; } @Override protected String[] getServletMappings() { return new String[] { "/" }; } }
Here is my security configuration:
@Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserDetailsService userDetailsService; @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService); } @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/resources/**"); } @Override protected void configure(HttpSecurity http) throws Exception {
And this is my login.html (example html from the timemeaf):
<form th:action="@{/j_spring_security_check}" method="post"> <label for="j_username">Username</label>: <input type="text" id="j_username" name="j_username" /> <br /> <label for="j_password">Password</label>: <input type="password" id="j_password" name="j_password" /> <br /> <input type="submit" value="Log in" /> </form>
When I click on the login, this error appears:
HTTP ERROR 404 Problem accessing /j_spring_security_check. Reason: Not Found
How can I get rid of this error? I googled a lot, but so far have not achieved anything. (Yes, I do not use xml.)
spring spring-mvc spring-security thymeleaf
akcasoy
source share