Skip to content

Commit 1805d42

Browse files
author
eugenp
committed
spring mvc xml config
1 parent 8a93af3 commit 1805d42

4 files changed

Lines changed: 58 additions & 60 deletions

File tree

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package org.baeldung.spring;
22

3-
import org.springframework.context.annotation.Bean;
43
import org.springframework.context.annotation.Configuration;
5-
import org.springframework.web.servlet.ViewResolver;
6-
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7-
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
4+
import org.springframework.context.annotation.ImportResource;
85
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9-
import org.springframework.web.servlet.view.InternalResourceViewResolver;
10-
import org.springframework.web.servlet.view.JstlView;
116

12-
@EnableWebMvc
7+
@ImportResource("classpath:webMvcConfig.xml")
138
@Configuration
149
public class ClientWebConfig extends WebMvcConfigurerAdapter {
1510

@@ -19,21 +14,4 @@ public ClientWebConfig() {
1914

2015
// API
2116

22-
@Override
23-
public void addViewControllers(final ViewControllerRegistry registry) {
24-
super.addViewControllers(registry);
25-
26-
registry.addViewController("/sample.html");
27-
}
28-
29-
@Bean
30-
public ViewResolver viewResolver() {
31-
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
32-
33-
bean.setViewClass(JstlView.class);
34-
bean.setPrefix("/WEB-INF/view/");
35-
bean.setSuffix(".jsp");
36-
37-
return bean;
38-
}
3917
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.baeldung.spring;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.web.servlet.ViewResolver;
5+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
8+
import org.springframework.web.servlet.view.JstlView;
9+
10+
//@EnableWebMvc
11+
//@Configuration
12+
public class ClientWebConfigOld extends WebMvcConfigurerAdapter {
13+
14+
public ClientWebConfigOld() {
15+
super();
16+
}
17+
18+
// API
19+
20+
@Override
21+
public void addViewControllers(final ViewControllerRegistry registry) {
22+
super.addViewControllers(registry);
23+
24+
registry.addViewController("/sample.html");
25+
}
26+
27+
@Bean
28+
public ViewResolver viewResolver() {
29+
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
30+
31+
bean.setViewClass(JstlView.class);
32+
bean.setPrefix("/WEB-INF/view/");
33+
bean.setSuffix(".jsp");
34+
35+
return bean;
36+
}
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc"
3+
xmlns:context="http://www.springframework.org/schema/context"
4+
xsi:schemaLocation="
5+
http://www.springframework.org/schema/beans
6+
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
7+
http://www.springframework.org/schema/context
8+
http://www.springframework.org/schema/context/spring-context-4.0.xsd
9+
http://www.springframework.org/schema/mvc
10+
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
11+
12+
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
13+
<property name="prefix" value="/WEB-INF/view/" />
14+
<property name="suffix" value=".jsp" />
15+
</bean>
16+
17+
<mvc:view-controller path="/sample.html" view-name="sample" />
18+
19+
</beans>

‎spring-mvc-xml/src/main/resources/webSecurityConfig.xml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)