This commit is contained in:
Katerina881 2023-02-07 11:35:24 +04:00
parent c3b722bde7
commit 39067b29fc

View File

@ -1,15 +1,35 @@
package com.example.springip.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Random;
@RestController
public class TestController {
@GetMapping("/test")
@GetMapping("/getRandomNumber")
public String getRandom() {
Random random = new Random();
return "Your number = " + random.nextInt(0,100);
}
@GetMapping("/sum")
public String getSum(@RequestParam(name = "val1", defaultValue = "1") int val1,
@RequestParam(name="val2",defaultValue = "2") int val2) {
return "Your summa = " + (val1 + val2);
}
@GetMapping("/upperCase")
public String toUpperCase(String word) {
if (word != null)
return word.toUpperCase();
return "Incorrect word";
}
@GetMapping("/length")
public String length(String name) {
return "Length = " + name.length();
}
}