网站建设资讯

NEWS

网站建设资讯

通过springboot写post请求

使用工具类

     
            cn.hutool
            hutool-all
            4.3.2
        

编写请求类

@Controller
public class UploadController {

    @RequestMapping("/{page}")
    public String showPage(@PathVariable String page) {
        return page;
    }

    @GetMapping("/posthttp")
    public String postparam(String param,Model model) {
        if (param.equals("")) {
            Person single = new Person("aa", 11);
            model.addAttribute("singlePerson", single);
            model.addAttribute("postcontent", "URL没有数据");
            return "person";
        } else {
            Person single = new Person("aa", 11);
            model.addAttribute("singlePerson", single);
//        System.out.println("这是提交的参数:"+param);
            HttpRequest httpRequest = HttpRequest.get(param);
            HttpResponse execute = httpRequest.execute();
//        System.out.println("这是结果"+execute.body());
            model.addAttribute("postcontent", execute.toString());
            return "person";
        }

响应

通过springboot写post请求

成都创新互联公司专业为企业提供昂昂溪网站建设、昂昂溪做网站、昂昂溪网站设计、昂昂溪网站制作等企业网站建设、网页设计与制作、昂昂溪企业网站模板建站服务,十余年昂昂溪做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

通过springboot写post请求


分享文章:通过springboot写post请求
文章网址:http://cdweb.net/article/jsooje.html