4 func
This commit is contained in:
parent
ca9e188161
commit
aa2273c97f
10
front/index.html
Normal file
10
front/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -2,12 +2,37 @@ package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.websocket.server.PathParam;
|
||||
import java.util.Date;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
|
||||
public class SbappApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SbappApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/hello")
|
||||
public Character hello(@RequestParam(value = "name", defaultValue = "World") String name) {
|
||||
return name.charAt(0);
|
||||
}
|
||||
@GetMapping("/hello_1/{name}")
|
||||
public String hello_1(@PathVariable String name, @RequestParam(required = false, defaultValue = "") String val) {
|
||||
name = name + val;
|
||||
return String.format("Hello %s!", name);
|
||||
}
|
||||
@GetMapping("/bd")
|
||||
public Integer bd(@RequestParam int birthday) {
|
||||
return new Date().getYear() % 100 + 2000 - birthday;
|
||||
}
|
||||
@GetMapping("/calc")
|
||||
public String doSum(@RequestParam(value = "v1", defaultValue = "") String val1, @RequestParam(defaultValue = "0") int val2) {
|
||||
return val1.substring(val2);
|
||||
}
|
||||
}
|
||||
|
15
src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java
Normal file
15
src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java
Normal file
@ -0,0 +1,15 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistration;
|
||||
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…
x
Reference in New Issue
Block a user