From 45c0260fc51bc1bb32d9bd96673785834f327bd1 Mon Sep 17 00:00:00 2001 From: eugenp Date: Mon, 29 Apr 2013 21:43:51 +0300 Subject: [PATCH] mvc work --- .../org.eclipse.wst.common.component | 21 ---------- spring-mvc/pom.xml | 38 ++++++++++++++++++- .../spring/web/config/ClientWebConfig.java | 34 +++++++++++++++++ 3 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java diff --git a/spring-mvc/.settings/org.eclipse.wst.common.component b/spring-mvc/.settings/org.eclipse.wst.common.component index c28f646be6..dcefbbc2ac 100644 --- a/spring-mvc/.settings/org.eclipse.wst.common.component +++ b/spring-mvc/.settings/org.eclipse.wst.common.component @@ -4,27 +4,6 @@ - - uses - - - uses - - - uses - - - uses - - - uses - - - uses - - - uses - diff --git a/spring-mvc/pom.xml b/spring-mvc/pom.xml index d2007ffe97..aeb0e7f9fb 100644 --- a/spring-mvc/pom.xml +++ b/spring-mvc/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.baeldung spring-mvc @@ -7,6 +8,19 @@ + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + @@ -102,4 +116,26 @@ + + + 3.2.2.RELEASE + + + 1.7.5 + 1.0.11 + + + 1.3 + 4.11 + 1.9.5 + + 4.2.4 + 4.2.4 + + 1.8.0 + 1.8.9 + + + + 0.1-SNAPSHOT \ No newline at end of file diff --git a/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java new file mode 100644 index 0000000000..2446e7b614 --- /dev/null +++ b/spring-mvc/src/main/java/org/baeldung/spring/web/config/ClientWebConfig.java @@ -0,0 +1,34 @@ +package org.baeldung.spring.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@EnableWebMvc +@Configuration +// @ComponentScan("org.package1.to.scan.web") +public class ClientWebConfig extends WebMvcConfigurerAdapter { + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); + + registry.addViewController("/sample.html"); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } +} \ No newline at end of file