软件园学生在线

  • {{ item.name }}
  • 2023试用期

登录与注册

【后端壹】孙棒棒

  • ninelifecat
  • 2022-10-14
  • 0
写在前面:由于我认为手高精度是麻烦且不必要的,所以没写(其实是懒)

由于学长保姆式的教学,我们可以很容易的推出加减乘除
以下是controller部分代码

package com.example.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Main {
    @GetMapping("/")
    public String helloWorld()
    {
              return "helloWorld";
    }

    @GetMapping("/add")
    public int add(@RequestParam int a, @RequestParam int b)
    {
        return a+b;
    }
    @GetMapping("/subtract")
    public int subtract(@RequestParam int a, @RequestParam int b)
    {

        return a-b;
    }
    @GetMapping("/multiply")
    public long multiply(@RequestParam long a, @RequestParam long b)
    {

        return a*b;
    }
    @GetMapping("/divide")
    public double divide(@RequestParam double a, @RequestParam double b)
    {
        return a/b;
    }
}
由于写css实在有些鸡肋,所以我们很聪明的选择了仿照自动生成API的链接跳转,然后我们就有了这样的index.html文件:

显示出来是这样

由于Markdown能识别,截图解决

ninelifecat
ninelifecat

八百万神明在我身后

© 2025 软件园学生在线
Theme by Wing