Add spring
This commit is contained in:
parent
dfaf8d35e8
commit
504c935b72
@ -2,20 +2,36 @@ package ru.ulstu.is.lab1;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
public class Lab1Application {
|
public class Lab1Application {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Lab1Application.class, args);
|
SpringApplication.run(Lab1Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/name")
|
@GetMapping("/minus")
|
||||||
public String hello(@RequestParam(value = "n", defaultValue = "World") String name) {
|
public @ResponseBody int toMinus(@RequestParam(defaultValue = "0") int v1,
|
||||||
return String.format("Hello %s!", name);
|
@RequestParam(defaultValue = "0") int v2) {
|
||||||
|
return v1 - v2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@GetMapping("/plus")
|
||||||
|
public @ResponseBody int toPlus(@RequestParam(defaultValue = "0") int v1,
|
||||||
|
@RequestParam(defaultValue = "0") int v2) {
|
||||||
|
return v1 + v2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/toUpperCase/{value}")
|
||||||
|
public @ResponseBody String toUpperCase(@PathVariable String value) {
|
||||||
|
return value.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/toLowerCase/{value}")
|
||||||
|
public @ResponseBody String toLowerCase(@PathVariable String value) {
|
||||||
|
return value.toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user