From ecc662501780e7337bc0ca0cda627bb95de3e104 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 4 Mar 2016 14:49:55 +0100 Subject: [PATCH] Add form tag example --- .../org/baeldung/spring/ClientWebConfig.java | 8 +-- .../baeldung/spring/ClientWebConfigJava.java | 53 +++++++++++++------ .../main/webapp/WEB-INF/view/personForm.jsp | 6 +-- .../main/webapp/WEB-INF/view/personView.jsp | 15 ------ .../src/main/webapp/WEB-INF/web.xml | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java index c4d819caa5..9705d51606 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfig.java @@ -8,10 +8,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration public class ClientWebConfig extends WebMvcConfigurerAdapter { - public ClientWebConfig() { - super(); - } + public ClientWebConfig() { + super(); + } - // API + // API } \ No newline at end of file diff --git a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java index d2b57da818..c82201880f 100644 --- a/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java +++ b/spring-mvc-xml/src/main/java/org/baeldung/spring/ClientWebConfigJava.java @@ -1,6 +1,12 @@ package org.baeldung.spring; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; +import org.springframework.context.support.MessageSourceResourceBundle; +import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -11,27 +17,40 @@ import org.springframework.web.servlet.view.JstlView; //@Configuration public class ClientWebConfigJava extends WebMvcConfigurerAdapter { - public ClientWebConfigJava() { - super(); - } + public ClientWebConfigJava() { + super(); + } - // API + @Bean + public MessageSource messageSource() { - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); + final ResourceBundleMessageSource ms = new ResourceBundleMessageSource(); + ms.setBasenames("messages"); + return ms; + } - registry.addViewController("/sample.html"); - } + @Bean + public ResourceBundle getBeanResourceBundle() { - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + final Locale locale = Locale.getDefault(); + return new MessageSourceResourceBundle(messageSource(), locale); + } - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + super.addViewControllers(registry); - return bean; - } + 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 diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp index 79bda7c17d..63d18a987c 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp @@ -24,7 +24,7 @@

Welcome, Enter The Person Details

- + @@ -104,10 +104,6 @@ Notes - - Select a file to upload - - diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp index 8893314d20..bd14474dfe 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp @@ -61,20 +61,5 @@ ${person.notes} - -

Submitted File

- - - - - - - - - - - - -
OriginalFileName :${person.file.originalFilename}
Type :${person.file.contentType}
\ No newline at end of file diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml index a39c4fdd3a..4e38b2fae6 100644 --- a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml +++ b/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml @@ -29,7 +29,7 @@ org.springframework.web.servlet.DispatcherServlet 1 - /tmp + C:/Users/ivan/Desktop/tmp