diff --git a/spring-boot-modules/spring-boot-mvc-4/README.md b/spring-boot-modules/spring-boot-mvc-4/README.md new file mode 100644 index 0000000000..651453c6d4 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/README.md @@ -0,0 +1,4 @@ +## Spring Boot MVC + +This module contains articles about Spring Web MVC in Spring Boot projects. + diff --git a/spring-boot-modules/spring-boot-mvc-4/pom.xml b/spring-boot-modules/spring-boot-mvc-4/pom.xml new file mode 100644 index 0000000000..edf6185259 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + spring-boot-mvc-4 + spring-boot-mvc-4 + jar + Module For Spring Boot + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-devtools + true + + + io.springfox + springfox-boot-starter + ${spring.fox.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${start-class} + JAR + + + + + + + + 3.0.0 + com.baeldung.springboot.swagger.ArticleApplication + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java similarity index 91% rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java rename to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java index 568d31e8bc..8be380baa0 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java @@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.spi.DocumentationType; @@ -12,6 +13,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication @EnableSwagger2 +@EnableWebMvc public class ArticleApplication { public static void main(String[] args) { diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java similarity index 91% rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java rename to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java index 96812e367a..c4336a7cfe 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java @@ -21,7 +21,7 @@ public class ArticlesController { } @PostMapping("") - public void addArticle(@RequestBody Article article) { + public void addArticle(@ModelAttribute Article article) { articleService.addArticle(article); } diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java similarity index 97% rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java rename to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java index 6512b4e1a7..f6318c04b3 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java @@ -15,6 +15,7 @@ public class Article { //@ApiModelProperty(hidden = true) //@ApiParam(hidden = true) //@ApiModelProperty(readOnly = true) + @ApiParam(hidden = true) private int id; private String title; private int numOfWords; diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java similarity index 99% rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java rename to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java index 04f6e6c6e3..3fd0279988 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java @@ -20,6 +20,6 @@ public class ArticleService { article.setId(articles.size() + 1); articles.add(article); } - + } diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/resources/static/index.html b/spring-boot-modules/spring-boot-mvc-4/src/main/resources/static/index.html new file mode 100644 index 0000000000..9f55d12685 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-4/src/main/resources/static/index.html @@ -0,0 +1 @@ +Welcome to Baeldung \ No newline at end of file