Добавлен фронтенд
This commit is contained in:
parent
bb58d473a3
commit
c8fe76f814
@ -2,9 +2,9 @@ package ru.ulstu.is.myapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@ -14,10 +14,41 @@ public class MyappApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MyappApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/hello")
|
||||
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
|
||||
return String.format("Hello %s!", name);
|
||||
}
|
||||
@CrossOrigin
|
||||
@GetMapping(value = "/add")
|
||||
public Integer doSum(@RequestParam(value = "a", defaultValue = "0") int a,
|
||||
@RequestParam(value = "b", defaultValue = "0") int b){
|
||||
return a + b;
|
||||
}
|
||||
@GetMapping("/sub")
|
||||
public Integer doSub(@RequestParam(value = "a", defaultValue = "0") int a,
|
||||
@RequestParam(value = "b", defaultValue = "0") int b){
|
||||
return a - b;
|
||||
}
|
||||
@GetMapping("/mul")
|
||||
public Integer doMul(@RequestParam(value = "a", defaultValue = "0") int a,
|
||||
@RequestParam(value = "b", defaultValue = "0") int b){
|
||||
return a * b;
|
||||
}
|
||||
@GetMapping("/del")
|
||||
public Integer doDel(@RequestParam(value = "a", defaultValue = "0") int a,
|
||||
@RequestParam(value = "b", defaultValue = "1") int b){
|
||||
return a / b;
|
||||
}
|
||||
@GetMapping("/mu")
|
||||
public String len(@RequestParam(value = "word", defaultValue = "") String name){
|
||||
return String.format("Длина слова " + name + " " + len(name));
|
||||
}
|
||||
@GetMapping("/de")
|
||||
public String root(){
|
||||
return new Date().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
14
src/main/java/ru/ulstu/is/myapp/WebConfiguration.java
Normal file
14
src/main/java/ru/ulstu/is/myapp/WebConfiguration.java
Normal file
@ -0,0 +1,14 @@
|
||||
package ru.ulstu.is.myapp;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry){
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user