Spring安全自定义登录页面,基于java的配置

时间:2015-12-05 18:41:07

标签: java spring spring-security

我使用基于Spring安全java的配置为基于servlet的web应用程序(没有spring mvc)。问题是如何设置自定义登录页面,因为spring生成了自己的登录页面?

这两个类完成了所有需要的工作,没有任何xml配置。那么如何使用此设置定义自定义登录jsp?

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        Context ctx = new InitialContext();
        DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/MyLocalDB");

        final String findUserQuery = "select username,password,enabled "
            + "from Employees " + "where username = ?";
        final String findRoles = "select username,role " + "from Roles "
            + "where username = ?";
            auth.jdbcAuthentication().dataSource(ds).usersByUsernameQuery(findUserQuery)
            .authoritiesByUsernameQuery(findRoles);
    }

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/*.html");
    }

}

public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {

    public SecurityWebApplicationInitializer() {
        super(SecurityConfig.class);
    }
}

1 个答案:

答案 0 :(得分:1)

请参阅Spring Security Reference

<div>
    <?=$some_variable?>
</div>