使用的是nutzbook的搜索,遇到个奇怪的现象,我把layout.html改造成了post提交,页面本事是utf8编码
<div itemscope itemtype="http://schema.org/WebSite">
<meta itemprop="url" content="${conf["website.urlbase"]}"/>
<form id='search_form' method="post" class='navbar-search' action="${ctxPath}/yvr/search" itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
<input type='text' id='q' name='q' class='search-query span3' value='' itemprop="query-input" placeholder="搜索用我" required/>
</form>
</div>
服务器端接受 代码
@Ok("beetl:/yvr/index.html")
@At({"/search", "/search/?"})
public Object search(int page, HttpServletRequest request) throws Exception {
request.setCharacterEncoding("utf-8");
long userId = Toolkit.uid();
String keys = request.getParameter("q");
if (Strings.isBlank(keys)){
return new ServerRedirectView("/yvr/list");
}
if(request.getMethod().equalsIgnoreCase("GET")){
keys = Toolkit._3DES_decode(queryKEY, Toolkit.hexstr2bytearray(keys));
}
log.infof("uid=%s,搜索词汇:%s", userId, keys);
List<String> listKey = Splitter.on(" ").splitToList(keys);
Cnd cndQuery = Cnd.where("onLine", "=", 1);
for(String key : listKey){
cndQuery.and("summaryinfo", "like", "%"+key.trim()+"%");
}
Pager pager = dao.createPager(page > 0 ? page : 1, pageSize);
pager.setRecordCount(dao.count(Mv_movie.class, cndQuery));
List<Mv_movie> list = dao.query(Mv_movie.class, cndQuery.orderBy("opAt", "desc"), pager);
NutMap re = processQueryList(pager, list, null, userId, "search/{page}?q="+Toolkit._3DES_encode(queryKEY, keys.getBytes()));
re.put("q", keys);
return re;
}
登入用户搜索没问题,非登入用户搜索就出现编码问题,下面是日志
12:54:05.041 INFO (YvrModule.java:328) search - uid=7039,搜索词汇:芳华
12:54:08.945 INFO (YvrModule.java:328) search - uid=-1,搜索词汇:é·ç¥3
12:54:14.600 INFO (YvrModule.java:328) search - uid=-1,搜索词汇:é·ç¥
12:55:14.275 INFO (YvrModule.java:328) search - uid=11593,搜索词汇:水形物语
12:55:22.752 INFO (YvrModule.java:328) search - uid=-1,搜索词汇:2017 ç¾å½ ç§å¹»
12:55:24.236 INFO (YvrModule.java:328) search - uid=-1,搜索词汇:红海è¡å
我本地没问题,是不是和线上linux机器编码问题有关系,那为啥登入用户编码没问题。编码拦截器只拦截登入用户请求?