POI Excel公式计算引擎服务
POI Excel公式计算引擎服务
计算引擎服务
Excel公式计算引擎服务
idea
Excel公式计算引擎服务
package com.example.demo.controller;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
-
@author :
-
@date :Created in 2020/11/5 10:37
-
@description:
-
@modified By:
-
@version: $
/
@Controller
public class TestController {
@ResponseBody
@RequestMapping(value = “/test”, method = RequestMethod.POST, produces = “application/json;charset=UTF-8”)
public String writeByBody(@RequestBody JSONObject jsonParam) {
// 直接将json信息打印出来
System.out.println(jsonParam.toJSONString());
//获取运算符
String name3 = jsonParam.getString(“name3”);
//获取第一个参数
String name2 = jsonParam.getString(“name2”);
//获取第二个参数
String name1 = jsonParam.getString(“name1”);
int result = 0;
//判断操作符
if (name3.equals("+")){//加法运算
result = Integer.parseInt(name2) + Integer.parseInt(name1);
} else if (name3.equals("-")){//减法运算
result = Integer.parseInt(name1) - Integer.parseInt(name2);
} else if (name3.equals("")){//乘法运算
result = Integer.parseInt(name2) * Integer.parseInt(name1);
} else if (name3.equals("/")){//除法运算
result = Integer.parseInt(name1) / Integer.parseInt(name2);
}// 把每个参数和操作符,以及运算封装成json格式,然后返回给前端JSONObject json = new JSONObject();json.put("msg", "ok");json.put("symbol", name3);json.put("name2", name2);json.put("name1", name1);json.put("result", result);return json.toJSONString();}
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
