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
随机推荐
- 新技能 get —— 使用 python 生成词云
什么是词云(word cloud)呢?词云又叫文字云,是对文本数据中出现频率较高的"关键词"在视觉上的突出呈现,形成关键词的渲染形成类似云一样的彩色图片,从而一眼就可以领略文本数据 ...
- TensorFlow 学习(九)—— 初始化函数(概率分布函数 api、常数生成函数)
在 TensorFlow 中,一个变量的值在被使用之前,其初始化过程需要被明确地调用. 1. 随机数生成函数 tensorflow 下的概率分布函数,一般用于对变量进行初始化,这里的变量显然是指神经网 ...
- java-线程-基础
线程状态及转化 借用网上的一幅图: 说明: 线程一共分为5种状态 新建状态(new) 线程对象被创建后,就进入了新建状态,例如:Thread t = new Thread(); 就绪状态(Runnab ...
- 【序列操作III】线段树
题目描述 给出序列 a1,a2,…an(0≤ai≤109),有关序列的四种操作: 1. al,al+1,…,ar(1≤l≤r≤n)加上 x(-103≤x≤103) 2. al,al+1,…,ar(1≤ ...
- 【Codeforces Round #438 A】Bark to Unlock
[链接]h在这里写链接 [题意] 在这里写题意 [题解] 枚举它是在连接处,还是就是整个字符串就好. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc+ ...
- Struts2——(5)转发和重定向(跨业务模块)
一.重定向redirect(默认是转发dispatcher)和转发的区别? 1.重定向浏览器的网址发生变化(相当于请求了两次),转发浏览器的网址不发生变化(只请求了一次). 2.重定向的过程:发送请求 ...
- Codeforces 444A DZY Loves Physics(图论)
题目链接:Codeforces 444A DZY Loves Physics 题目大意:给出一张图,图中的每一个节点,每条边都有一个权值.如今有从中挑出一张子图,要求子图联通,而且被选中的随意两点.假 ...
- Spring Assert.notNull--IllegalArgumentException
Exception in thread "main" java.lang.IllegalArgumentException: Source must not be null at ...
- 傅里叶分析(matlab)
一维信号的傅里叶变换:fft(t) 二维图像的傅里叶变换:fft2(t) fft2(x) ⇒ fft(fft(x)')' 0. 基础 f(t)=∑k=−∞∞αkeikt 1. frequency sp ...
- Matlab随笔之模拟退火算法
问题描述: 我方有一个基地,经度和纬度为( 70,40).假设我方飞机的速度为 1000 公里/小时. 我方派一架飞机从基地出发,侦察完敌方所有目标,再返回原来的基地.在敌方每一目 标点的侦察时间不计 ...