Compare commits

...

2 Commits

Author SHA1 Message Date
Pineapple
2c6869c6db Готова 2023-04-03 12:29:00 +04:00
Pineapple
ee645d78cf Готова 2023-04-03 12:28:03 +04:00
2 changed files with 35 additions and 17 deletions

View File

@ -0,0 +1,35 @@
package com.example.demo.Controller;
import org.springframework.web.bind.annotation.*;
@RestController
@CrossOrigin
public class Controllers {
@GetMapping("/plus")
public @ResponseBody Integer Plus (@RequestParam (required = false, defaultValue = "0") int val1,
@RequestParam (required = false, defaultValue = "0") int val2){
return val1 + val2;
}
@GetMapping("/minus")
public @ResponseBody Integer Minus (@RequestParam (required = false, defaultValue = "0") int val1,
@RequestParam (required = false, defaultValue = "0") int val2){
return val1 - val2;
}
@GetMapping("/mult")
public @ResponseBody Integer Mult (@RequestParam (required = false, defaultValue = "0") int val1,
@RequestParam (required = false, defaultValue = "0") int val2){
return val1 * val2;
}
@GetMapping("/div")
public @ResponseBody Integer Div (@RequestParam (required = false, defaultValue = "0") int val1,
@RequestParam (required = false, defaultValue = "1") int val2){
return val1 / val2;
}
}

View File

@ -1,17 +0,0 @@
package com.example.demo.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class Main {
@GetMapping
public String helloWorld(@RequestParam(name = "name", required = false, defaultValue = "World") String name, Model model){
model.addAttribute( "name", name);
return "hello-world!";
}
}