我们昨天撰写完serviceImpl还缺少一个interface,
所以今天把ShioajiService补上,
程序如下:
public interface ShioajiService {
public String test(String tickdate) throws Exception;
}
service、serviceImpl都完成後,
再来就是controller,
我们要先设定controller和方法的mapping路径,
还需要设定http method,
之後用request.getParameter来取得url传过来的日期,
再执行我们昨天写的连接python api的方法,
取得回传资料後,把格式从json string转为json array。
程序如下:
@Controller
@RequestMapping("/shioaji")
public class ShioajiController {
@Autowired
private ShioajiService shioajiService;
@RequestMapping(value = "/show" , method = {RequestMethod.GET})
public void show(Model model, HttpServletRequest pRequest) throws Exception {
String tickdate = pRequest.getParameter("tickdate") == null ? "" : pRequest.getParameter("tickdate");
String tick_data = shioajiService.test(tickdate);
JSONArray jsonArray = new JSONArray(tick_data);
model.addAttribute("jsonArray", "jsonArray");
// return "toShow";
}
}
今天先到执行完API方法後,确认没问题,
明天要开始做HTML视觉化的部分。
MySQL 是免费的关联式资料库,具有轻量级速度快的优点,适合小型网站架设使用。 目前最流行的 Wo...
今天分享程序码从github更新到replit的步骤还有要注意的点 步骤 replit有自带储存环境...
Traces - 观察应用程序的效能瓶颈 系列文章 (1/6) - Elastic APM 基本介绍...
为何我要写这篇 嗨,大家好(其实没人) 大部分的人应该都有追求的经验(2D,3D我都很理解),那在追...
本篇文章同步发表在 HKT 线上教室 部落格,线上影音教学课程已上架至 Udemy 和 Youtu...