File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .baeldung .spring ;
22
3- import org .springframework .context .annotation .Bean ;
43import 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 ;
85import 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
149public 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}
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 >
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments