[TOC]
1.get参数
@RequestMapping(value = "/{appId}/url", method = RequestMethod.GET)
@ResponseBody
public String getParam1(@PathVariable Long appId, @RequestParam String url) {
System.out.println(appId);
System.out.println(url);
return "redirect:" + StringEscapeUtils.unescapeHtml(url);
}
- 测试页面和返回
2.body传输数据
@RequestMapping(value = "/url", method = RequestMethod.POST)
@ResponseBody
public String getParam2(@RequestBody Param param) {
System.out.println(param.getAppId());
System.out.println(param.getUrl());
return "redirect:" + StringEscapeUtils.unescapeHtml(param.getUrl());
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Param {
Long appId;
String url;
}
- 测试页面和返回
3.form传输数据
@RequestMapping(value = "/url", method = RequestMethod.GET)
@ResponseBody
public String getParam3(Param param) {
System.out.println(param.getAppId());
System.out.println(param.getUrl());
return "redirect:" + StringEscapeUtils.unescapeHtml(param.getUrl());
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Param {
Long appId;
String url;
}
- 测试页面以及返回
网友评论