} catch (UnsupportedEncodingException e) {
logger.warn(e.getMessage(), e);
}
Collection<FilterElementVo> filters = new ArrayList<FilterElementVo>();
StringBuilder sb = new StringBuilder();
FilterElementVo filter = null;
// add city filter
filter = new FilterElementVo();
filter.setType("city");
filter.setTypeLabel("城市");
filter.setValue("");
filter.setLabel("全国");
if (StringUtils.hasText(city)) {
CityMeta cityMeta = cityMetaRepository.getByPinyin(city
.toLowerCase());
if (cityMeta == null) {
cityMeta = cityMetaRepository
.getByPinyin(ApplicationConfig.defaultCityPinyin);
}
if (cityMeta != null) {
filter.setLabel(cityMeta.getName());
filter.setValue(cityMeta.getPinyin());
}
}
filters.add(filter);
sb.append(filter.getType()).append("=").append(filter.getValue())
.append("&");
// add gender filter
filter = new FilterElementVo();
filter.setType("gender");
filter.setTypeLabel("性别");
filter.setValue("");
filter.setLabel("无所谓");
if (StringUtils.hasText(gender)) {
try {
Gender g = Gender.valueOf(gender.toUpperCase());
filter.setLabel(DomainObjectUtil.getGender(g));
filter.setValue(gender);
} catch (RuntimeException re) {
}
}
filters.add(filter);
sb.append(filter.getType()).append("=").append(filter.getValue())
.append("&");
// add keyword filter
filter = new FilterElementVo();
filter.setType("keyword");
filter.setTypeLabel("关键词");
filter.setValue("");
filter.setLabel("未选择");
if (StringUtils.hasText(keyword)) {
filter.setLabel(keyword);
filter.setValue(keyword);
}
filters.add(filter);
sb.append(filter.getType()).append("=").append(filter.getValue())
.append("&");
model.addAttribute("filters", filters);
model.addAttribute("qStr", sb.toString());
return "profiles";