zl程序教程

您现在的位置是:首页 >  其他

当前栏目

关于量化合约代码教程及合约量化系统开发部署流程

2023-06-13 09:13:57 时间

量化机器人添加代码 教程

  • 添加类MyController:
package com.kb.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MyController
{
	@RequestMapping("/controller1")
	public String controllerFunc1(Model m)
	{
		m.addAttribute("msg","hello controller 1");
		return "test";
	}
	@RequestMapping("/controller2")
	public String controllerFunc2(Model m)
	{
		m.addAttribute("msg","hello controller 2");
		return "test";
	}
	@RequestMapping("/controller3")
	public String controllerFunc3(Model m)
	{
		m.addAttribute("msg","hello controller 3");
		return "test";
	}
}

这里使用注解的方式,有三个方法可以被前端调用,分别为controllerFunc1controllerFunc2controllerFunc3;URL分别为http://localhost:8080/controller1http://localhost:8080/controller2http://localhost:8080/controller3。由于springmvc-servlet.xml里配置了web访问的路径前缀包括jsp,因此在WEB-INFO路径下添加jsp文件夹,并创建test.jsp文件。

<%--
  Created by IntelliJ IDEA.
  User: KingBoy
  Date: 2021/11/14
  Time: 19:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
${msg}
</body>
</html>

部署

  • 到这里项目部分完成。配置部署环境。打开configuration,配置Tomcat路径,不要用太新的Tomcat,7 8 什么的都可以。deployment里添加项目。
  • configuration右边有个小文件夹按钮,即project structure配置,进到artifact里,在WEB-INFO里面添加一个lib文件夹,将maven的库都添加,否则会有404错误。
  • 启动项目。OK