0

I've generated a Spring Boot web application using Spring Initializr, using embedded Tomcat + Thymeleaf template engine, and package as an executable JAR file.

Technologies used :

Spring Boot 1.4.2.RELEASE, Spring 4.3.4.RELEASE, Thymeleaf 2.1.5.RELEASE, Tomcat Embed 8.5.6, Maven 3, Java 8

This is my security config class:

@Configuration
@PropertySource("classpath:/com/tdk/iot/config/app-${APP-KEY}.properties")
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Value("${securityConfig.formLogin.loginPage}")
    private String loginPage;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
            .formLogin()
                .loginPage(loginPage)
                .defaultSuccessUrl("/books/list")
                .permitAll()
                .and()
            .exceptionHandling()
                .accessDeniedPage("/denied")
                .and()
            .authorizeRequests()
                .antMatchers("/mockup/**").permitAll()
                .antMatchers("/dinners/**").permitAll()
                .antMatchers("/welcome/**").authenticated()
                .and()
            .logout()
                .permitAll()
                .logoutSuccessUrl("/index.html");
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth
            .inMemoryAuthentication()
                .passwordEncoder(new StandardPasswordEncoder())
                .withUser("test1").password("test1").roles("ADMIN").and()
                .withUser("test2").password("test2").roles("USER").and()
                .withUser("test3").password("test3").roles("SUPERADMIN");
    }




    @Bean
    public  static PropertySourcesPlaceholderConfigurer propertyDefaultConfig() {
        return new PropertySourcesPlaceholderConfigurer();
    }
}

and this is my login template

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
...
</head>
    <div class="wrap">
        <div class="login">
            <div class="logo"><img src="../../../images_pebloc/login.png" width="224" height="71"  /></div>

              <form th:action="@{/login.html}" method="post">
                <p th:if="${loginError}" class="error">Wrong user or password</p>
                    <div class="input_label"><i class="fa fa-user"></i><input type="text" name="user" placeholder="User" /></div>
                    <div class="input_label"><i class="fa fa-key"></i><input type="password" name="pass" placeholder="Password" /></div>

                </form>

              <input type="submit" value="LOGIN" />
            <div class="forget">
                <a href="#">Do you forgot your password?</a><br/>
                <br/>
                <span>tdk</span>
            </div>

        </div>
    </div>

but when I click nothing happens, no HTML error in the console, no javascript error, no form error, no submit, wherever I put in the form

0

1 Answer 1

1
+50

Your submit button isn't inside the form tag. Move it inside of the </form> and that should trigger your action.

Not the answer you're looking for? Browse other questions tagged or ask your own question.