⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchaction.java

📁 MVC构架
💻 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 + -