Springmvc中@RequestParam传值中文乱码解决方案(转)


    @RequestMapping(value={"/list"},method=RequestMethod.GET)
    @ResponseBody
    public DeviceList getdevicelist(HttpServletRequest request, HttpServletResponse response) {
        

        String m_unit=request.getParameter("khnuit");
        m_unit=EncodingTool.encodeStr(m_unit);
        DeviceList ds=new DeviceList(deviceService.find(m_unit),1,0,20);
        return ds;
    }
    public static class EncodingTool {  
        public static String encodeStr(String str) {  
            try {  
                return new String(str.getBytes("ISO-8859-1"), "UTF-8");  
            } catch (UnsupportedEncodingException e) {  
                e.printStackTrace();  
                return null;  
            }  
        }  
    }  

原文地址:http://luanxiyuan.iteye.com/blog/1849169


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM