您的位置:首页 > 其它

实习小记3

2016-07-13 14:15 211 查看
1. freemarker中前端页面的 selecet标签

<li class="normal" style="background:none;"><@s.select name="operatorName" list="allOperators" CssStyle="width:200px;"/></li>

name 标签指定的operatorName,则对应的后台action中,有一个private operatorName,并拥有get set方法。

list属性指定的allOperatorors是一个get方法,后台action中有public Map<String, String> getAllOperators()的get方法。此map中如果这样存放(id,name)。

在页面中,如果在select中选择某个选项,点击提交,那么传递的是Key值,而不是value。在这里就是Id,而不是name。通过set方法,operatorName被设值注入为,所选下拉 框的值对应的Id。

2.

public PageItInfo<OperationLog> getObjectsByOperatorNameAndOperationAndLogTimeForPages(

String operatorName, String operation,

Timestamp logTime, long pageNum, int pageSize, String orderField,

boolean isAsc) {

DetachedCriteria detachedCriteria = DetachedCriteria

.forClass(persistentClass);

if (logTime != null) {

detachedCriteria.add(Restrictions.le("logTime", logTime));

}

if (!StringUtils.isBlank(operatorName)) {

detachedCriteria

.add(Restrictions.eq("operatorName", operatorName));

}

if (!StringUtils.isBlank(operation)) {

detachedCriteria.add(Restrictions.like("action", operation,MatchMode.ANYWHERE));

}

return joinGetObjectsForPage(detachedCriteria, pageNum, pageSize, new String[]{orderField}, new boolean[]{isAsc}, false, "");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: