Bael 3395 - spring optional path var (#8341)

* initial test cases

* changes in @requestMapping

* moving code to spring-mvc-basic-2 project

* moving Article class
This commit is contained in:
M-Abdelbaset 2019-12-10 19:13:07 +02:00 committed by maibin
parent 337c83b463
commit 96d4c3c95b
10 changed files with 8 additions and 26 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung.model;
package com.baeldung.controller.optionalpathvars;
public class Article {

View File

@ -1,13 +1,11 @@
package com.baeldung.controller.optionalpathvars;
import static com.baeldung.model.Article.DEFAULT_ARTICLE;
import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.model.Article;
@RestController
public class ArticleViewerController {

View File

@ -1,6 +1,6 @@
package com.baeldung.controller.optionalpathvars;
import static com.baeldung.model.Article.DEFAULT_ARTICLE;
import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE;
import java.util.Map;
@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.model.Article;
@RestController
@RequestMapping(value = "/mapParam")
public class ArticleViewerWithMapParamController {

View File

@ -1,14 +1,12 @@
package com.baeldung.controller.optionalpathvars;
import static com.baeldung.model.Article.DEFAULT_ARTICLE;
import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE;
import java.util.Optional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.model.Article;;
import org.springframework.web.bind.annotation.RestController;;
@RestController
@RequestMapping("/optionalParam")

View File

@ -1,12 +1,10 @@
package com.baeldung.controller.optionalpathvars;
import static com.baeldung.model.Article.DEFAULT_ARTICLE;
import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.model.Article;;
import org.springframework.web.bind.annotation.RestController;;
@RestController
@RequestMapping(value = "/requiredAttribute")

View File

@ -1,13 +1,11 @@
package com.baeldung.controller.optionalpathvars;
import static com.baeldung.model.Article.DEFAULT_ARTICLE;
import static com.baeldung.controller.optionalpathvars.Article.DEFAULT_ARTICLE;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.model.Article;
@RestController
@RequestMapping(value = "/seperateMethods")
public class ArticleViewerWithTwoSeparateMethodsController {

View File

@ -12,8 +12,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.model.Article;
import org.baeldung.controller.config.WebConfig;
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -12,8 +12,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.model.Article;
import org.baeldung.controller.config.WebConfig;
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -12,8 +12,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.model.Article;
import org.baeldung.controller.config.WebConfig;
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -12,8 +12,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.model.Article;
import org.baeldung.controller.config.WebConfig;
@RunWith(SpringJUnit4ClassRunner.class)