tomcat部署war包,页面传递中文参数报错。
传递中文参数需要编码和解码
var targetUrl = "${basePath}/search?keyword=" + encodeURIComponent(encodeURIComponent(strSearch)); window.location.href= targetUrl;
@RequestMapping("search") public String search(Model model,String keyword) throws UnsupportedEncodingException { keyword = URLDecoder.decode(keyword, "utf-8"); model.addAttribute("keyword",keyword); return "web/search"; }