使用工具类
<代码> & lt; dependency> & lt; groupId> cn.hutool & lt; artifactId> hutool-all & lt; version> 4.3.2 & lt;/dependency> 代码>
编写请求类
<代码> @ controller 公开课UploadController { @RequestMapping("/{页面}") 公共字符串showPage (@PathVariable字符串页面){ 返回页面; } @GetMapping ("/posthttp”) postparam公共字符串(字符串参数,模型模型){ 如果(param.equals (" ")) { 人单身=new (“aa”, 11); 模型。addAttribute(“哪个穆巴拉克”,单); 模型。addAttribute (“postcontent”、“URL没有数据”); 返回“人”; 其他}{ 人单身=new (“aa”, 11); 模型。addAttribute(“哪个穆巴拉克”,单);//System.out.println(“这是提交的参数:”+参数); HttpRequest HttpRequest=HttpRequest.get(参数); HttpResponse执行=httpRequest.execute ();//System.out.println(“这是结果”+ execute.body ()); 模型。addAttribute (“postcontent execute.toString ()); 返回“人”; } 代码>
响应