资源预览内容
第1页 / 共13页
第2页 / 共13页
第3页 / 共13页
第4页 / 共13页
第5页 / 共13页
第6页 / 共13页
第7页 / 共13页
第8页 / 共13页
第9页 / 共13页
第10页 / 共13页
亲,该文档总共13页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
部分代码展示如下:图片验证码生成代码如下(CheckCodeAciton):public class CheckCodeAction extends Actionpublic ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)response.setContentType(image/jpeg);/ 图片的内存映像BufferedImage image=new BufferedImage(60,25,BufferedImage.TYPE_INT_RGB);/ 获得画笔对象Graphics g = image.getGraphics();Random r = new Random();g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255);g.fillRect(0, 0, 60, 25);g.setColor(new Color(0,0,0);String str = ;for(int i=0;i=pages)bookListForm.setPage(pages);page=pages;if(pagebooks = DAOFactory.getBookDAO().findByParentId(scc,beginIndex, size);request.getSession().setAttribute(counts, counts);if(pages=0)pages = 1;购物车核心代码 CartService:public class CartService private Map store = new HashMap();public CartService()public static CartService getInstance(HttpSession session)CartService cart = (CartService)session.getAttribute(cart);if(cart = null)cart = new CartService();session.setAttribute(cart, cart);return cart;public void add(Integer id)if(store.containsKey(id)CartItem item = store.get(id);item.setNum(item.getNum()+1);elseBook book = DAOFactory.getBookDAO().findById(id);CartItem item = new CartItem();item.setPro(book);store.put(id,item);public void delete(Integer id)if(store.containsKey(id)CartItem item = store.get(id);item.setBuy(false);public void delete(boolean flag)Set set = store.entrySet();Iterator it = set.iterator();while(it.hasNext()Map.Entry entry = (Map.Entry)it.next();CartItem item = (CartItem)entry.getValue();if(item.isBuy()=flag)it.remove();public void recovery(Integer id)if(store.containsKey(id)CartItem item = store.get(id);item.setBuy(true);public double cost(boolean flag)double sum = 0;List items = getItems(true);for(int i=0;i getItems(boolean isbuy)List items = new ArrayList();Set set = store.entrySet();Iterator it = set.iterator();while(it.hasNext()Map.Entry entry = (Map.Entry)it.next();CartItem item = (CartItem)entry.getValue();if(item.isBuy()=isbuy)items.add(item);return items;Ajax异步请求代码如下:$(function() $(#address).change(function()if($(this).html!=填写新地址)$.ajax(url:/select.do,type:post,data:$(#address).serialize(),dataType:json,success:function(data,status)$(#receiveName).val(data.receive_name);$(#fullAddress).val(data.full_address);$(#postalCode).val(data.postal_code);$(#phone).val(data.phone);$(#mobile).val(data.mobile);,error:function(xhr,textStatus,errorThrown)alert(xhr.status););););ManagerLoginAction代码如下:public class ManagerLoginAction extends Actionpublic ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)ManagerLoginForm managerForm = (ManagerLoginForm)form;String managername = managerForm.getManagername();String password = managerForm.getPassword();if(managername.trim().equals(sunjinfu) & password.trim().equals(sunluoyang1987)request.getSession().setAttribute(manager_error, null);request.getSession().setAttribute(manager, success);return mapping.findForward(index);elserequest.getSession().setAttribute(manager_error, 管理员登录验证失败);return mapping.findForward(manager_login);部分页面代码如下:function collapse_change(menucount) if ($(menu_ + menucount).style.display = none) $(menu_ + menucount).style.display = ;$(menuimg_ + menucount).src = css/main/menu_reduce.gif; else $(menu_ + menucount).style.display = none;$(menuimg_ + menucount).src = css/main/menu_add.gif;var menus = new Array(g1,g2,g3,g4);function togglemenu(id) for (i = 0; i SearchUserAction代码如下:public class SearchUserAction extends Actionpublic ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)UserManageForm manageForm = (UserManageForm)form;String email_id = manageForm.getEmail_id();User user = null;String reg1 = .1,30w2,10.2,10;String reg2 = 0-9+$;UserDAOImpl userDAO = (UserDAOImpl) DAOFactory.getUserDAO();if(email_id.matches(reg1)user = userDAO.findByEmail(email_id.trim();else if(email_id.matches(reg2)user = userDAO.findById(Integer.parseInt(email_id.trim();request.getSession().setAttribute(user_error, null);manageForm.setUser(user);return mapping.findForward(user_detail);/ elserequest.getSession().setAttribute(user_error, 您的输入有误!);return mapping.findForward(user_list);Ajax级联动态下拉框代码如下:$(function()$(#superCategory).change(function()if($(this).html!=选择分类)$.ajax(url:/getcategory.do,type:post,data:$(#superCategory).serialize(),dataType:json,success:function(data,status)document.getElementById(category).innerHTML=;for(var i=0;i/getsubcategory.do,type:post,data:$(#category).serialize(),dataType:json,success:function(data,status)$(#whichCategory).val(data.name);,error:function(xhr,textStatus,errorThrown)alert(xhr.status););
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号