bookqueryaction.java
来自「一个基本的图书馆管理系统」· Java 代码 · 共 74 行
JAVA
74 行
package c18.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import c18.helper.PageBean;
import c18.helper.PageResult;
import c18.service.BookService;
import c18.service.BookServiceImpl;
import c18.struts.action.exception.ActionException;
import c18.util.ConvertUtil;
/**
*
* 关键字搜索Action类
* @struts.action path="/book_query" scope="request"
* @struts.action-forward name="success" path="/book_querylist.jsp"
*/
public class BookQueryAction extends Action{
/**
* 日志操作对象
*/
private static final Log log = LogFactory.getLog(BookQueryAction.class);
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//得到查询关键字
String findKey = request.getParameter("findKey");
if(findKey == null){
findKey = "";
}
//得到查询类型
int findType =0;
String sfindType = request.getParameter("findType");
if(sfindType != null && !sfindType.equals("")){
findType = ConvertUtil.convertInt(sfindType);
}
PageBean pageBean = PageBean.getPageBean(request, response);
try {
//创建BookService对象
BookService bookservice = new BookServiceImpl();
//查询图书
PageResult pageresult = bookservice.findBooksByKey(findKey, findType, pageBean);
//在Request中放入查询结果
request.setAttribute("findKey", findKey);
request.setAttribute("findType", findType);
request.setAttribute("pageresult", pageresult);
} catch (ActionException e) {
log.error(e);
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?