[BAEL-19881] - Rename spring-mvc-simple modules
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.controller.optionalpathvars;
|
||||
|
||||
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;
|
||||
|
||||
@RestController
|
||||
public class ArticleViewerController {
|
||||
|
||||
@RequestMapping(value = {"/article", "/article/{id}"})
|
||||
public Article getArticle(@PathVariable(name = "id") Integer articleId) {
|
||||
|
||||
if (articleId != null) {
|
||||
return new Article(articleId);
|
||||
} else {
|
||||
return DEFAULT_ARTICLE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user