标签:dir ppi pat err request arch 生成 servlet str
@RequestMapping(value = {"/search"}) public String errorPath(HttpServletResponse response, @RequestParam(value = "keyword") String keyword, @RequestParam(value = "via") String via) throws IOException { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); String url = "/search/"+ URLEncoder.encode(keyword, "UTF-8")+"/4"; response.setHeader("Location", url); response.sendRedirect(url); return ""; }
在这个例子中,如果没有加URLEncoder.encode(keyword, "UTF-8"),运行的时候会发现生成的url是有问题的,
这个时候就需要把keyword给encoder.
标签:dir ppi pat err request arch 生成 servlet str
原文地址:http://www.cnblogs.com/qianxinxu/p/6223474.html