1. The front desk form is directly posted or get, and the background is received in the form of request.getParameterMap() or request.getParameter()
Note: Foreground, springmvc filter, and jsp, compiler encoding all take utf-8 as an example
Take request.getParameterMap() as an example
Note: Here is a method to get parameters from HttpServletRequest, and as for request, it is similar to
@RequestMapping("/tradePortal/ReceiveCommands") public ModelAndView receiveCommands(HttpServletRequest request, HttpServletResponse response){}Getting it from this method
public static Map<String,String> getParamters(HttpServletRequest request){ logger.info("Start get request parameter"); Map<?,?> paramterMap = request.getParameterMap(); Map<String,String> paraMap = new ConcurrentHashMap<String, String>(); for (Map.Entry entry : paramterMap.entrySet()) { if (Array.getLength(entry.getValue())<1||StringUtil.isEmpty(((String)(Array.get(entry.getValue(),0))))){ paraMap.put((String)entry.getKey(),null); }else { if (request.getMethod().equalsIgnoreCase("get")){ try { paraMap.put((String)entry.getKey(),new String((String)(Array.get(entry.getValue(),0))).getBytes("ISO-8859-1"),"utf-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }else { paraMap.put((String)entry.getKey(),(String)(Array.get(entry.getValue(),0))); } } } logger.info("The parameter is completed. The parameter is: "+ JSON.toJSONString(paraMap)); return paraMap; }The above article solves the problem of garbled code in the form post, get to springMVC backend is all the content I share with you. I hope it can give you a reference and I hope you can support Wulin.com more.