Chinese Messy Code of String
It'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, -);
}
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.


Chinese Messy Code of String的更多相关文章
- Messy Code in Windows Server 2008 R2 English Edition
We always use Windows Server 2008 R2 English operation system. And it doesn't have any problem ...
- the solution about "messy code" in elicpse
I use the Elicpse IDE to develope the ansdroid app.Sometime encounter the messy code in the Elicpse ...
- .net 中文显示乱码问题(Chinese display with messy code)
Case:同样的代码,本地开发环境(local is Chinese Simplify)可以成功运行,但是放到Windows Server 2008 R2(Local is United State) ...
- UVa——1593Alignment of Code(string重定向+vector数组)
UVA - 1593 Alignment of Code Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & ...
- C++ code:string stream(string流)
如果有一个文件aaa.txt,有若干行,不知道每行中含有几个整数,要编程输出每行的整数之和,该如何实现? 由于cin>>不能辨别空格与回车的差异,因此只能用getline的方式逐行读入数据 ...
- 【Leet Code】String to Integer (atoi) ——常考类型题
String to Integer (atoi) Total Accepted: 15482 Total Submissions: 106043My Submissions Implement ato ...
- [PHP] find ascii code in string
if (strpos($data ,chr(0x95)) !== false) { echo 'true'; }else{ echo "false"; }
- BNU OJ 50998 BQG'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; # ...
- IS Kali: installed chiess messy code problem
apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy init 6
随机推荐
- wpf datagrid 的单元格内容超出列宽度
---恢复内容开始--- <Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.mi ...
- ANR问题分析实例
ANR监测机制包含三种: Service ANR,前台进程中Service生命周期不能超过20秒,后台进程中Service的生命周期不能超过200秒. 在启动Service时,抛出定时消息SERVIC ...
- Swagger 专题
随着互联网技术的发展,现在的网站架构基本都由原来的后端渲染,变成了:前端渲染.前后端分离的形态,而且前端和后端在各自的技术道路上越走越远. 前端和后端的唯一联系,变成了API接口:API文档成了前后端 ...
- Zygote总结
Zygote是由init进程通过解析 init.zygote.rc 文件而创建的,zygote所对应的可执行程序 app_process,所对应的源文件是App_main.cpp,进程名为zygote ...
- [Android]TextView实现分散对齐(两端对齐)
TextView是个特别基础的Android控件,只要有文本基本就少不了它.但是最近在项目开发的过程中我发现TextView存在很多局限性,其中最令我头疼的就是TextView文本排版方面的问题.我们 ...
- Android app 第三方微信支付接入详解
微信支付做了好几遍了,都没有出现什么棘手的问题,下面一一为大家分享一下,欢迎吐槽. 还是老样子,接入微信的支付要第一步添加微信支付官方的包libammsdk.jar 首先就处理略坑的一个问题,app应 ...
- 用C语言编写简单的病毒
[摘要]在分析病毒机理的基础上,用C语言写了一个小病毒作为实例,用TURBOC2.0实现. [Abstract] This paper introduce the charateristic of t ...
- Delphi程序员如何找到高薪的工作?(赚不到钱,原因只有一个,就是他们没有被公司录取。Delphi必须要独自进行深入研究,才能精通,同时也不能自由性太强)
转帖自:http://www.tommstudio.com/ViewNews.aspx?ID=187http://hi.baidu.com/rarnu/blog/ 本文翻译自<美国优秀经理观念大 ...
- Qtcreator中常用快捷键总结(有必要牢记,提高编程效率)
F1 查看帮助F2 跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2 声明和定义之间切换F4 头文件和源文件之间切换Ctrl+1 ...
- windows 10 使用 tricks
全新的环境变量编辑界面, 全新的[任务管理器]⇒ [性能] 0. 添加开机启动项 将要添加的开机自启动软件的快捷方式添加到如下的路径: C:\Users\hasee\AppData\Roaming\M ...