public class SupplyorAction extends PageActionBase{ @Override public void onLoad() { String actiontype = request.getParameter("actiontype"); System.out.println("actiontype=" + actiontype); if (actiontype == null) return ; } /******************************************************** ******************信息注销监听支持***************************** *********************************************************/ public void delete() { String id=request.getParameter("id"); DALBase.delete("supplyor", " where id="+id); binding(); }public void save() { String forwardurl=request.getParameter("forwardurl"); //验证错误url String errorurl=request.getParameter("errorurl"); String sname=request.getParameter("sname"); String tel=request.getParameter("tel"); String lxren=request.getParameter("lxren"); String email=request.getParameter("email"); String address=request.getParameter("address"); String fax=request.getParameter("fax"); String des=request.getParameter("des"); SimpleDateFormat sdfsupplyor=new SimpleDateFormat("yyyy-MM-dd"); Supplyor supplyor=new Supplyor(); supplyor.setSname(sname==null?"":sname); supplyor.setTel(tel==null?"":tel); supplyor.setLxren(lxren==null?"":lxren); supplyor.setEmail(email==null?"":email); supplyor.setAddress(address==null?"":address); supplyor.setFax(fax==null?"":fax); supplyor.setDes(des==null?"":des); //产生验证 Boolean validateresult=saveValidate( "where sname='"+sname+"'"); if(validateresult){ try { request.setAttribute("errormsg","<label class='error'>已存在的供应商</label>"); request.setAttribute("supplyor", supplyor); request.setAttribute("actiontype", "save"); request.getRequestDispatcher(errorurl).forward(request, response); } catch (Exception e) { e.printStackTrace(); } return; } DALBase.save(supplyor); //保存附件 // attachments(request,response,new Integer(supplyor.getId()).toString()); if(forwardurl==null){ forwardurl="/admin/supplyormanager.do?actiontype=get"; } try { response.sendRedirect(SystemParam.getSiteRoot()+forwardurl); } catch (Exception e) { e.printStackTrace(); } } //新增验证 private boolean saveValidate(String filter){ return DALBase.isExist("supplyor解释每一行代码
时间: 2023-07-19 19:52:41 浏览: 79
java中的多态共2页.pdf.zip
这是一个Java类,继承了PageActionBase类。该类实现了onLoad()方法,其中获取了请求参数中的actiontype,并打印输出。如果actiontype为空,则直接返回。另外,该类还包含了delete()和save()方法,分别用于删除和保存供应商信息。在save()方法中,首先获取请求参数中的各项信息,然后对sname进行重复性验证。若验证结果为true,则设置错误信息并返回;否则,将供应商信息保存到数据库中。最后,根据请求参数中的forwardurl跳转到指定页面。私有方法saveValidate()用于对sname进行验证,如果已存在相同的sname,则返回true。
阅读全文