小任班长 发布的文章

el表达式截取 逗号后面的字符串
${fn:substringAfter(strVar,',' )}

el表达式判断字段长度
<c:if test="${fn:length(strVar)>65 }">

</c:if>


el表达式截取字符串长度
${fn:substring(strVar,0,16 )}

//hibernate 返回对象指定属性,需要返回的列,可以直接返回 对象属性
@OverridepublicTeamPlan getTeamPlanByBaoMingId(String baomingid){
Criteria cr
=this.getSession().createCriteria(BaoMingInfo.class);
cr.setProjection(Projections.property(
"teamplan"));//需要返回的列,可以直接返回 对象属性 cr.add(Restrictions.eq("id", baomingid));//条件 return(TeamPlan)cr.uniqueResult();
}


@Override
publicInteger getSumBaseXuNiZuoWeiByTpid(String teamPlanID){
String hql
="select sum(basexunizuoweishu) from TeamPlanXuNiZuoWeiEntity where teamplanid=:teamplanid";
Query query
=this.getSession().createQuery(hql);
query.setString(
"teamplanid", teamPlanID);return(Integer)query.uniqueResult();
}

 

这种方式serviceImpl 方法不用throws异常,比较方便if(count>0){//或者 IllegalArgumentException java的
     throw new IllegalArgumentException("msg");//这个是poi的异常
     throw new IllegalPropertySetDataException("msg");
}

前台得到后台定义的异常字符串
}
catch(Exception e) {
message
=e.getMessage();
e.printStackTrace();
}

 

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。