一、将地址栏参数封装到map
接收的中文参数不需要处理乱码,使用springboot1.5.9版本
@RequestParam Map<String, String> searchMap:封装的参数
http://localhost:9031/search?keywords=手机
key=keywords,value=手机
RequestParam 只封装地址栏参数,对于restTemplate.getForObject的第三个参数不会封装
@GetMapping("search")//请求参数 searchMap
public String search(Model model,@RequestParam Map<String, String> searchMap) throws Exception {
//get方式 需要处理乱码
// searchMap=WebUtil.convertCharsetToUTF8(searchMap);
// Map result = skuSearchService.search(searchMap);
// Map result = restTemplate.getForObject(PREFIX + ":9001/search", Map.class, searchMap);
// Map result = restTemplate.getForObject(PREFIX + ":9001/search?keywords=" + searchMap.get("keywords"), Map.class, searchMap);
Map result = restTemplate.getForObject(PREFIX + ":9001/search?keywords=" + searchMap.get("keywords"), Map.class);
model.addAttribute("result",result);
return "result";
}