Skip to content

Commit

Permalink
Add SpringConfig.java fixes mkyong#1
Browse files Browse the repository at this point in the history
  • Loading branch information
timthelion committed Dec 10, 2022
1 parent bf66cc7 commit 4c0d03f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions java-web-project/src/main/java/com/mkyong/web/SpringConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

package com.mkyong.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

@EnableWebMvc
@Configuration
@ComponentScan({"com.mkyong.web"})
public class SpringConfig implements WebMvcConfigurer {

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

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

0 comments on commit 4c0d03f

Please sign in to comment.