2017-03-05 11 views
0

Spring Initializrを使用して、埋め込みTomcat + Thymeleafテンプレートエンジンを使用し、実行可能なJARファイルとしてパッケージを使用して、SpringブートWebアプリケーションを生成しました。使用Thymeleaf + Springセキュリティインテグレーション

技術:

春ブーツ1.4.2.RELEASE、春4.3.4.RELEASE、Thymeleaf 2.1.5.RELEASE、Tomcatの埋め込み8.5.6、Mavenの3、Javaの8

これは、私のセキュリティ設定クラス:

@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(); 
    } 
} 

と、これは私のログインテンプレート

<!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> 

私です何も起こらない、コンソールにHTMLエラーがない、JavaScriptエラーがない、フォームエラーがない、提出しない、フォームに書いたときどこでも

答えて

1

送信ボタンがformタグの中にない。 </form>の内部に移動してください。

関連する問題