81,095
社区成员
发帖
与我相关
我的任务
分享
public class noticeDaoImpl extends HibernateDaoSupport implements noticeDao {
public List<Notice> dimFindNotice(Notice notice,String end) {
Criteria c = getSession().createCriteria(Notice.class);
if(notice !=null){
if(notice.getTitle()!= null && notice.getTitle().trim().length() !=0){
c.add(Restrictions.like("title",notice.getTitle(),MatchMode.ANYWHERE));
}
if(notice.getPublishstate()!=null && notice.getPublishstate().trim().length()!=0){
c.add(Restrictions.eq("publishstate",notice.getPublishstate()));
}
if(notice.getCratedate()!=null && notice.getCratedate().trim().length()!=0){
c.add(Restrictions.like("cratedate",notice.getCratedate(),MatchMode.START));
}
if(end!="" && end.trim().length()!=0){
c.add(Restrictions.between("cratedate",notice.getCratedate(),end));
/*String sql = "select * from notice where cratedate between '"+notice.getCratedate()+"' and '"+end+"'";
c.add(Restrictions.sqlRestriction(sql));*/
}
}
return c.list();
}
package com.HRM.action.notice;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.HRM.Service.noticeService;
import com.HRM.entity.Notice;
import com.opensymphony.xwork2.ActionSupport;
public class dimNoticeAction extends ActionSupport{
private noticeService ns;
private Notice notice;
private String end;
@Override
public String execute() throws Exception {
System.out.println(notice.getCratedate());
System.out.println(end);
HttpSession se = ServletActionContext.getRequest().getSession();
List<Notice> list= (List<Notice>)ns.dimFindNotice(notice,end);
se.setAttribute("dimnotice",list);
return SUCCESS;
}
public noticeService getNs() {
return ns;
}
public void setNs(noticeService ns) {
this.ns = ns;
}
public Notice getNotice() {
return notice;
}
public void setNotice(Notice notice) {
this.notice = notice;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
}