標籤:ram 轉碼 bsp res ffffff ogg public att color
@RequestMapping("/judge") public String judgeLogger(@RequestParam String userName, @RequestParam String password, @RequestParam String sex, RedirectAttributes redirectAttributes) {// 亂碼解決方案 try { String name = new String(userName.getBytes("iso-8859-1"), "UTF-8"); String s = new String(sex.getBytes("iso-8859-1"), "utf-8");
//-------------------------------------------------------------------------------- if (name != null && password != null && s != null) { if (loggerService.judgeLogger(name)==1) { redirectAttributes.addFlashAttribute("userName",name); redirectAttributes.addFlashAttribute("password",password); redirectAttributes.addFlashAttribute("sex",s); return "redirect:/log.do"; } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); return "404"; } return "404"; }
在傳遞過來的前台資料進行一次轉碼即可解決。但是我之前設定過request和response的編碼,但是然並卵。
springmvc前台傳遞到controller層的中文亂碼解決方案