📄 searchaction.java
字号:
package addressbook.actions;import addressbook.Constants;import addressbook.forms.*;import addressbook.model.*;import org.apache.struts.action.*;import javax.servlet.http.*;public class SearchAction extends Action { public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { /**@todo: complete the business logic here, this is just a skeleton.*/ SearchForm searchForm = (SearchForm) actionForm; String name=searchForm.getName(); String phone=searchForm.getPhone(); String address=searchForm.getAddress(); String strSql=new String("select * from book where "); if(!name.equals("")) strSql=strSql+"name LIKE '"+name+"%' AND"; if(!phone.equals("")) strSql=strSql+"phone LIKE '"+phone+"%' AND"; if(!address.equals("")) strSql=strSql+"address LIKE '"+address+"%'"; else strSql=strSql.substring(0,strSql.length()-3); strSql=strSql+" order by ID"; HttpSession session=httpServletRequest.getSession(); session.setAttribute("session",strSql); //System.out.println(session.getAttribute("session")); return (actionMapping.findForward("view")); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -