replace requestmapping, update properties

This commit is contained in:
Loredana Crusoveanu
2018-05-06 23:02:49 +03:00
parent b4d4d4ec08
commit 88a3f6c0fe
15 changed files with 43 additions and 52 deletions

View File

@@ -6,6 +6,7 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -22,7 +23,7 @@ public class UserController {
private static final Logger LOG = LoggerFactory.getLogger(UserController.class);
@RequestMapping("")
@GetMapping("")
public List<User> getAllUsers() {
LOG.info("Fetching all the users");
return Arrays.asList(

View File

@@ -4,7 +4,7 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import com.baeldung.displayallbeans.service.FooService;
@@ -13,7 +13,7 @@ public class FooController {
@Autowired
private FooService fooService;
@RequestMapping(value = "/displayallbeans")
@GetMapping(value = "/displayallbeans")
public String getHeaderAndBody(Map<String, Object> model) {
model.put("header", fooService.getHeader());
model.put("message", fooService.getBody());

View File

@@ -3,7 +3,7 @@ package com.baeldung.errorhandling.controllers;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
@@ -13,7 +13,7 @@ public class MyErrorController implements ErrorController {
public MyErrorController() {}
@RequestMapping(value = "/error")
@GetMapping(value = "/error")
public String handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);

View File

@@ -1,7 +1,7 @@
package com.baeldung.git;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@@ -19,7 +19,7 @@ public class CommitInfoController {
@Value("${git.commit.id}")
private String commitId;
@RequestMapping("/commitId")
@GetMapping("/commitId")
public Map<String, String> getCommitId() {
Map<String, String> result = new HashMap<>();
result.put("Commit message", commitMessage);

View File

@@ -1,17 +1,17 @@
package com.baeldung.intro.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HomeController {
@RequestMapping("/")
@GetMapping("/")
public String root() {
return "Index Page";
}
@RequestMapping("/local")
@GetMapping("/local")
public String local() {
return "/local";
}

View File

@@ -1,14 +1,14 @@
package com.baeldung.rss;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/rss", produces = "application/*")
public class ArticleRssController {
@RequestMapping(method = RequestMethod.GET)
@GetMapping
public String articleFeed() {
return "articleFeedView";
}

View File

@@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@@ -27,7 +27,7 @@ public class WarInitializerApplication extends SpringBootServletInitializer {
@RestController
public static class WarInitializerController {
@RequestMapping("/")
@GetMapping("/")
public String handler(Model model) {
model.addAttribute("date", LocalDateTime.now());
return "WarInitializerApplication is up and running!";

View File

@@ -2,12 +2,12 @@ package com.baeldung.webjar;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class TestController {
@RequestMapping(value = "/")
@GetMapping(value = "/")
public String welcome(Model model) {
return "index";
}