• javaweb 解决jsp中${}传递中文值到后端以及get请求中文乱码的问题


    首先,不要用get传中文,我试了一些方法发现不行,所以果断决定用post传参,

    这里用 encodeURI 进行一次编码传入后端

    注意:${tplname} 要加 '

            $.ajax({
                url: '/RM/controller/json/ConfigTemplateCustomController/fetchTemplateCustomContentsByTplName/tplname/post',
                type: 'POST',
                async: false,
                data:{
                  'tplname':encodeURI('${tplname}')
                },
                success:

    这样解码后再 getBytes 就解决了

        @RequestMapping(value = "controller/json/ConfigTemplateCustomController/fetchTemplateCustomContentsByTplName/tplname/post", method = RequestMethod.POST)
        @ResponseBody
        public BaseResult fetchTemplateCustomContentsByTplName(String tplname) throws UnsupportedEncodingException {
            tplname = URLDecoder.decode(tplname,"utf-8");
            tplname =  new String(tplname.getBytes("ISO-8859-1"),"UTF-8");
            return ResultUtil.success().add("TemplateCustom", configTemplateCustomService.selectByPrimaryKey(tplname));
        }
  • 相关阅读:
    Emacs 安装 jedi
    PHP+ MongoDB
    Debian 7 安装 Emacs 24.3
    在Code first中使用数据库里的视图
    Emacs安装auto-complete
    Debian 7.4 中配置PHP环境
    ASP.NET MVC 下载列表
    JDicom使用指南
    Windows常用的DOS命令
    Entity Framework问题总结
  • 原文地址:https://www.cnblogs.com/kinome/p/9983735.html
Copyright © 2020-2023  润新知