项目创建controlle包
创建一个类叫SetTimeController
这里类名和文件名需要一致,否则不能路由
代码如下,
RequestMapping 的value=SetTime一定要与SetTimeController保持一致
方法名试了试,叫啥都行
package com.example.rtspDemo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
public class SetTimeController {
@RequestMapping(value = "/SetTime", method = RequestMethod.POST)
public String SetTime(HttpServletRequest request, HttpServletResponse response){
String starttime = request.getParameter("starttime");
String endtime = request.getParameter("endtime");
return "ok:"+starttime+"-"+endtime;
}
}
创建完运行测试这边使用PostMan发送请求
结果如图