I will use the angular.js and did download some examples only that all use .jsp pages and would like to use .html. My setup is only in java config, I'm not using XML, however I am trying to make the MVC spring solve html pages and I'm not getting, and am trying to implement using this class ..

http://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/view/UrlBasedViewResolver.html

My WebAppConfig

@Configuration
@EnableWebMvc
@ComponentScan("com")
public class WebAppConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/login").setViewName("login");
    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}

public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}

@Bean
public UrlBasedViewResolver setupViewResolver() {
    UrlBasedViewResolver resolver = new UrlBasedViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    resolver.setViewClass(JstlView.class);
    return resolver;
}

Blockquote

resolver just jsp pages, I try */

 @Bean
 public UrlBasedViewResolver setupViewResolver() {
    UrlBasedViewResolver resolver = new UrlBasedViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".html");
    resolver.setViewClass(JstlView.class);
    return resolver;
}






@Bean
public UrlBasedViewResolver setupViewResolver() {
    UrlBasedViewResolver resolver = new UrlBasedViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    resolver.setViewClass(JstlView.class);
    return resolver;
}

@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource source = new ResourceBundleMessageSource();
    source.setBasename("messages");
    return source;
}

}

security configuration

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {


@Autowired 
@Qualifier("autenticacaoDetalhesProvider")
private AuthenticationProvider autenticacaoProvider;

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
    .authorizeRequests()
    .antMatchers("/resources/**").permitAll()
    .anyRequest().authenticated()
    .and()
    .formLogin()
    .loginPage("/login")
    .permitAll()
    .and()
    .logout()
    .logoutRequestMatcher( new AntPathRequestMatcher( "/logout" ) )
    .logoutSuccessUrl( "/home" )
    .deleteCookies( "JSESSIONID" )
    .invalidateHttpSession( true )
    .and()
    .sessionManagement()
    .invalidSessionUrl( "/login?time=1" )
    .maximumSessions( 1 );
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(this.autenticacaoProvider);
}

}

My inicilizer

 @Order(1)
public class Initializer extends  AbstractAnnotationConfigDispatcherServletInitializer        
implements WebApplicationInitializer {

@Override
protected Class<?>[] getRootConfigClasses() {
    return new Class[] {DatabaseConfig.class};
}

@Override
protected Class<?>[] getServletConfigClasses() {
    return new Class<?>[] {WebAppConfig.class };
}

@Override
protected String[] getServletMappings() {
    return new String[] { "/" };
}

}

my dir

webapp
resources
web-inf
views
|-home.html
|-login.html

Att

Related posts

Recent Viewed