6 Sale_id 外键 3 Int 参照SaleEstate
序号 1 2 序号 1 2 序号 1 2 3 4 5 6
字段名称 Id
Typename
字段名称 Id
TypeName
字段名称 Id
Content leavedate Name Mysaleid Myshopping
表10(状态表)
约束 宽度 类型
8-18 Int 主键
Not null 14 Char 表11(商品的类型) 约束 宽度 类型 主键 8-18 Int Not null 14 Char 表12(留言模块表) 约束 宽度 类型 主键 8-18 Int 256 Char Notnull Date
30 Char Notnull 30 Notnull 30
Default
Default Default
字段说明 保持唯一 类型名字 字段说明 保持唯一 类型名字 字段说明 保持唯一 留言内容 留言日期 作者 外键 外键
4 系统实现 4.1 程序设计 用户登录界面:
图6 用户登录界面
用户登录核心代码:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
String key = request.getParameter(\ List list = new ArrayList(); if (key == null) {
firstUser f = (firstUser) form; String name = f.getNames(); String password = f.getPwd();
String regx = \
第10页
}
ActionMessages ms = new ActionMessages(); boolean flag = true;
if (!(name.matches(regx))) {
ActionMessage m = new ActionMessage(\ ms.add(\ flag = false; }
if (!(password.matches(regx))) {
ActionMessage m = new ActionMessage(\ ms.add(\ flag = false; }
BysjService bs = new BysjServiceImpl(); if (flag == true) {
try {
Users u = bs.seachName(name, password)
Set
HttpSession session = request.getSession(); session.setAttribute(\ } catch (DataAccessException e) {
ActionMessage m = new ActionMessage(\ ms.add(\ flag = false;
} catch (DataErrorException e) {
ActionMessage m = new ActionMessage(\ ms.add(\ flag = false; } }
if (!flag) {
saveErrors(request, ms);
return mapping.getInputForward(); }
return mapping.findForward(\
第11页
return mapping.findForward(\ }
1)会员登录模块: 会员发布出售信息:
图7 发布出售信息平台界面
发布出售信息核心代码:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try {
AddMysaleFrom amf = (AddMysaleFrom) form; HttpSession session = request.getSession(); File file = null;
List list = (List) session.getAttribute(\ Users u = (Users) list.get(0);
BysjService bs = new BysjServiceImpl();
String str = bs.addMysale(amf, u.getLoaduser());
ServletContext sc = getServlet().getServletContext();
String fileurl = sc.getRealPath(\ file = new File(fileurl); if (file.isDirectory()) {
// System.out.println(\ } else {
file.mkdir(); }
String fileurls = fileurl + \ System.out.println(fileurl); byte[] b = new byte[1024];
FormFile ff = amf.getUploads(); try {
InputStream is = ff.getInputStream();
OutputStream os = new FileOutputStream(fileurls);
第12页
while (true) {
int c = is.read(b); os.write(b); if (c < 1024) {
break; } }
String tempUrl = \ BysjService bss = new BysjServiceImpl(); bss.addMysales(amf, tempUrl, u.getId()); } catch (FileNotFoundException e) {
e.printStackTrace(); } catch (IOException e) {
e.printStackTrace(); }
} catch (DataAccessException e) {
return mapping.findForward(\ }
return null; }
会员个人资料管理:
图8 会员个人资料管理界面
会员个人资料管理核心代码:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String id=request.getParameter(\
Users users=new AjaxUserDaoImpl().findById(id); request.setAttribute(\ return null;
第13页
}
留言模块:
图9 留言功能界面
留言的后台代码:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(); SavemsgForm sm = (SavemsgForm) form;
String mysaleid = request.getParameter(\ Message ms = new Message(); ms.setAuthor(sm.getAuthor()); ms.setContent(sm.getContent()); ms.setMysaleid(sm.getMysaleid()); Mysale mysaleids = new Mysale(); mysaleids.setId(mysaleid);
DateFormat df = new SimpleDateFormat(\ String time = df.format(new Date()); ms.setTime(time);
MessageImpl msg = new MessageImpl(); ms.setMaysale(mysaleids); msg.insert(ms);
List list = msg.getMessagebyMysaleId(sm.getMysaleid()); request.setAttribute(\
request.setAttribute(\ return mapping.findForward(\ }高级查询模块:
图10 高级查询模块界面
高级查询模块代码:
第14页