校园二手交易系统的设计与实现本科毕业论文 下载本文

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

String pageIndex=request.getParameter(\ AllMysall am= new AllMysall(); if (pageIndex==null){ pageIndex=\ }

String shoppingname=request.getParameter(\ String where=request.getParameter(\ String sql=\

if(shoppingname!=null&&shoppingname.length()>0) {

sql+=\

}

if(where!=null && where.length()>0) {

sql+=\}

Pagepage=(Page)am.seachMysall(sql, Integer.parseInt(pageIndex));

request.setAttribute(\return mapping.findForward(\

}

2)管理员模块: 商品类别管理:

图11 商品类别管理界面

商品管理后台代码:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

List list = new AjaxMerchandiseTypeImpl().seachMerchandise(); request.setAttribute(\ return mapping.findForward(\ }

第15页

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

String id = request.getParameter(\ String type = request.getParameter(\

MerchandiseType mt = new AjaxMerchandiseTypeImpl().findById(id); mt.setType(type);

return mapping.findForward(\ }

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String type=request.getParameter(\ MerchandiseType mt=new MerchandiseType(); mt.setType(type);

new AjaxMerchandiseTypeImpl().insert(mt); return mapping.findForward(\ }

留言信息管理:

图12 留言信息管理界面

留言管理后台代码:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

String id=request.getParameter(\ MessageImpl msg = new MessageImpl(); msg.deleteById(id);

return mapping.findForward(\

}

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

MessageImpl mi= new MessageImpl();

第16页

List list=mi.getMessagebyAll(); request.setAttribute(\ return mapping.findForward(\ }

出售信息管理:

图13 出售信息管理界面

出售信息核心代码:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String id=request.getParameter(\

Mysale ms=new MysalePersistImpl().findById(id); request.setAttribute(\ return mapping.findForward(\ }

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { HttpSession session=request.getSession(); List list=(List)session.getAttribute(\ Users u=(Users)list.get(0);

BysjService bs= new BysjServiceImpl(); Users ut=bs.showMysale(u);

request.setAttribute(\ return mapping.findForward(\ }

用户注册模块:

第17页

图14 用户注册界面

用户注册后台代码:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { Userss u=(Userss)form; String names=u.getNames(); String namem=u.getNamem(); String pwd=u.getPwd(); String email=u.getEmail(); String idcard=u.getIdcard(); String sex= u.getSex();

String specialty=u.getSpecialty(); String classs= u.getClasss();

String rgx2=\ String rgx=\

String rgxemail=\ ActionMessages ms= new ActionMessages(); boolean flag=true;

if(!(names.matches(rgx))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(namem.matches(rgx2))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(pwd.matches(rgx))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(email.matches(rgxemail))){

ActionMessage m= new ActionMessage(\

第18页

ms.add(\ flag=false; }

if(!(idcard.matches(rgx))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(sex.matches(rgx2))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(specialty.matches(rgx2))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!(classs.matches(rgx2))){

ActionMessage m= new ActionMessage(\ ms.add(\ flag=false; }

if(!flag){

saveErrors(request, ms);

return mapping.getInputForward(); }

BysjService bs= new BysjServiceImpl(); try{

bs.insertUsers(u);

}catch (DataAccessException e) {

request.setAttribute(\ return mapping.getInputForward(); }

return mapping.findForward(\ }

3)权限控制:

第19页