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:
parent
337c83b463
commit
96d4c3c95b
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.model;
|
package com.baeldung.controller.optionalpathvars;
|
||||||
|
|
||||||
public class Article {
|
public class Article {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.baeldung.controller.optionalpathvars;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ArticleViewerController {
|
public class ArticleViewerController {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.baeldung.controller.optionalpathvars;
|
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;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/mapParam")
|
@RequestMapping(value = "/mapParam")
|
||||||
public class ArticleViewerWithMapParamController {
|
public class ArticleViewerWithMapParamController {
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package com.baeldung.controller.optionalpathvars;
|
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 java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;;
|
||||||
|
|
||||||
import com.baeldung.model.Article;;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/optionalParam")
|
@RequestMapping("/optionalParam")
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package com.baeldung.controller.optionalpathvars;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;;
|
||||||
|
|
||||||
import com.baeldung.model.Article;;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/requiredAttribute")
|
@RequestMapping(value = "/requiredAttribute")
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.baeldung.controller.optionalpathvars;
|
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/seperateMethods")
|
@RequestMapping(value = "/seperateMethods")
|
||||||
public class ArticleViewerWithTwoSeparateMethodsController {
|
public class ArticleViewerWithTwoSeparateMethodsController {
|
||||||
|
|
|
@ -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.result.MockMvcResultMatchers;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
import org.baeldung.controller.config.WebConfig;
|
import org.baeldung.controller.config.WebConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
|
|
@ -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.result.MockMvcResultMatchers;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
import org.baeldung.controller.config.WebConfig;
|
import org.baeldung.controller.config.WebConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
|
|
@ -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.result.MockMvcResultMatchers;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
import org.baeldung.controller.config.WebConfig;
|
import org.baeldung.controller.config.WebConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
|
|
@ -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.result.MockMvcResultMatchers;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.model.Article;
|
|
||||||
import org.baeldung.controller.config.WebConfig;
|
import org.baeldung.controller.config.WebConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
|
Loading…
Reference in New Issue