Close

Spring MVC - @Configuration Examples

[Last Updated: Nov 9, 2025]

Spring MVC 

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebMvc
@Configuration
@ComponentScan
public class TradeConfig implements WebMvcConfigurer {
@Autowired
private TradeService tradeService;

@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
registry.jsp("/WEB-INF/views/", ".jsp");
}


@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new TradeIdToTradeConverter(tradeService));
}

}
Original Post




See Also

Join