Chinese Messy Code of String

I‘s very strange that I found the messy code.I ‘ve never seen this before.

this is the java code:

    /**
     * list
     *
     * @throws UnsupportedEncodingException
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public String list(Long adminId, String operation, Date beginDate,
            Date endDate, Pageable pageable, ModelMap model)
    {
        if (null == endDate)
        {
            endDate = new Date();
        }

        //query 30day before by default
        if (null == beginDate)
        {
            beginDate = DateUtils.addDays(endDate, -30);
        }
        List<LogConfig> logConfigs = logConfigService.getAll();
        List<Admin> admins = adminService.findAll();
        model.addAttribute("admins", admins);
        model.addAttribute("logConfigs", logConfigs);
        model.addAttribute("adminId", adminId);
        model.addAttribute("page", logService.findPage(adminId, operation,
                beginDate, endDate, pageable));
        model.addAttribute("operation", operation);
        model.addAttribute("beginDate", beginDate);
        model.addAttribute("endDate", endDate);
        return "/admin/log/list";
    }

And the String parameter "operation" was always messy code.

I thought it was the matter of FreeMarker. If the front end code gave a String as a object.so background program would got a address of object.

but that is wrong.It is just different with the messy code.

Finally I added this two lines code:

        if (operation != null)
        {
            operation = (new String(operation.getBytes("ISO-8859-1"), "utf-8"))
                    .trim();
        }

that‘s ok.

but that‘s not the best way.

tomcat‘s encoding setting is the key of the problem.

时间: 2025-01-09 15:50:51

Chinese Messy Code of String的相关文章

the solution about &quot;messy code&quot; in elicpse

I use the Elicpse IDE to develope the ansdroid app.Sometime encounter the messy code in the Elicpse One solve method is that to fix the Ecicpse's enCoding setting: click "Windows->Preferences->General->Content Type",in the right tab,mak

BNU OJ 50998 BQG&#39;s Messy Code

#include <cstdio> #define _(l) int l #define ___(l,L) for (_(o)=0,x=l o*2;o<x;o++)O= L o; #define __ _ ( _ ) const __=0x80000000; _(main)() { int T; scanf("%d",&T); while(T--){ _(O); scanf("%d",&O); if(O&_)___(-,-~

the solution about &amp;quot;messy code&amp;quot; in elicpse

I use the Elicpse IDE to develope the ansdroid app.Sometime encounter the messy code in the Elicpse One solve method is that to fix the Ecicpse's enCoding setting: click "Windows->Preferences->General->Content Type",in the right tab,mak

【Leet Code】String to Integer (atoi) ——常考类型题

String to Integer (atoi) Total Accepted: 15482 Total Submissions: 106043My Submissions Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yours

C++ code:string stream(string流)

如果有一个文件aaa.txt,有若干行,不知道每行中含有几个整数,要编程输出每行的整数之和,该如何实现? 由于cin>>不能辨别空格与回车的差异,因此只能用getline的方式逐行读入数据到string变量中,但在string变量中分离若干个整数还是稍显吃力.一个好的方法是用string流: 1 #include<iostream> 2 #include<sstream> 3 #include<fstream> 4 using namespace std;

[PHP] find ascii code in string

if (strpos($data ,chr(0x95)) !== false) { echo 'true'; }else{ echo "false"; }

Invoke-WebRequest Invoke-RestMethod 乱码研究

powershell Invoke-WebRequest Invoke-RestMethod 乱码 encoding sharset CharacterSet 原创,世界唯一,说明了Invoke-WebRequest Invoke-RestMethod 乱码的原因,给出了解决方案. powershell 传教士 原创文章 2016-05-01 允许转载,但必须保留名字和出处,否则追究法律责任 ------------[第一章 编码知识点]----------------- 编码类型,和编码值,是

关于java.io.IOException: Server returned HTTP response code: 400 for URL报错和string.getBytes()字符集

400 请求出错:由于语法格式有误,服务器无法理解此请求总论:这种错误应该会有很多原因,这里指出的是因为字符集编码的原因导致400,主要代码:向服务器发送请求传输json参数用的是out.write(json.getBytes())(读取的是操作系统的字符集,如果操作系统与部署项目的服务器不同则报错);改为out.writeChars(json);或out.write(json.getBytes(服务器编码))即可.如下代码16行 1 //创建连接 2 URL url = new URL(u);

从零开始学习前端JAVASCRIPT — 3、JavaScript基础string字符串介绍

1:字符串 JS中的任何数据类型都可以当作对象来看.所以string既是基本数据类型,又是对象. 2:声明字符串 基本数据类型:var sStr = '字符串'; 对象的方法:var oStr = new String('字符串'); //统计每个字符出现的次数,结果显示 a 2.b 1.c 2.d1,去掉重复的字符,使结果显示 abcdfgj. //var定义的变量赋值字符串以对象[]的方式访问单个字符IE8以上支持 var str="abcdafgcj"; var arr={};