📄 selectguestbookaction.java
字号:
package com.enlen.book;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.uniland.common.CallService;
import com.uniland.dao.DaoParam;
import com.uniland.dao.RowSet;
public class SelectGuestBookAction extends Action {
/**
* Constructor
*/
public SelectGuestBookAction() {
super();
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RowSet rsQuery = new RowSet();
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();
// RowSet rs = ( (UpdateGuestBookForm) form).getRowSet();
// request.setAttribute("guestbook",rs);
boolean validated = true;
String strWhere = "";
try {
String strSQL = "select * from guestbook where 1=1 ";
String title = request.getParameter("title");
if (title == null || title.trim().equals("")) {
title = "";
} else {
title = " and title like '%" + title + "%'";
}
String time = request.getParameter("time");
if (time == null || time.trim().equals("")) {
time = "";
} else {
time = " and time like " + CallService.getDao().getSQLDate(time + " 00:00:00")+ "";
}
String id = request.getParameter("oper");
if (id == null || id.trim().equals("")) {
id = "";
} else {
id = " and oper = '" + id+ "'";
}
System.out.println("strSQL==" + strSQL);
strWhere += title + time+id;
strSQL = strSQL + strWhere;
rsQuery = CallService.getDao().runSQLReturnRS(strSQL);
} catch (Exception e) {
e.getStackTrace();
validated = false;
}
if (validated == true) {
request.getSession().setAttribute("guestbook", rsQuery);
return (mapping.findForward("success"));
}
else {
saveErrors(request, errors);
return (mapping.findForward("fail"));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -