<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page import="cn.jvsun.DAO.Impl.*" %> <%@ page import="cn.jvsun.POJO.*" %> <%@ page import="cn.jvsun.DAO.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"https://www.jb51.net/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="https://www.jb51.net/<%=basePath%>" > <title>del</title> </head> <body> <% int pid=Integer.parseInt(request.getParameter("pid")); int result=0; UpDAO dao=new UpDAOImpl(); result=dao.delPhoto(pid); if(result==1){ out.println("<script>alert('删除成功');window.location.href('show.jsp');</script>"); }else{ out.println("<script>alert('出错了');window.location.href('show.jsp');</script>"); } %> </body> </html>
del.jsp删除相册
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page import="cn.jvsun.DAO.Impl.*" %> <%@ page import="cn.jvsun.POJO.*" %> <%@ page import="cn.jvsun.DAO.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"https://www.jb51.net/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="https://www.jb51.net/<%=basePath%>" > <title>del</title> </head> <body> <% int aid=Integer.parseInt(request.getParameter("aid")); int result=0; UpDAO dao=new UpDAOImpl(); result=dao.delAlbum(aid); if(result==1){ out.println("<script>alert('删除成功');window.location.href('index.jsp');</script>"); }else{ out.println("<script>alert('删除失败,请先把相册中的照片删掉');window.location.href('index.jsp');</script>"); } %> </body> </html>
数据库的建表语句:
-- Create table create table USERINFO ( ID NUMBER, USERNAME VARCHAR2(30), PASSWORD VARCHAR2(30) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255 storage ( initial 64 minextents 1 maxextents unlimited ); -- Create/Recreate primary, unique and foreign key constraints alter table USERINFO add constraint PID primary key (ID) disable; --上传者 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- Create table create table ALBUM ( ID NUMBER not null, A_NAME VARCHAR2(30), USER_ID NUMBER ) tablespace USERS pctfree 10 initrans 1 maxtrans 255 storage ( initial 64 minextents 1 maxextents unlimited ); -- Create/Recreate primary, unique and foreign key constraints alter table ALBUM add constraint AL_PID primary key (ID) using index tablespace USERS pctfree 10 initrans 2 maxtrans 255 storage ( initial 64K minextents 1 maxextents unlimited ); alter table ALBUM add constraint USERID foreign key (USER_ID) references USERINFO (ID) disable; --相册表 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- Create table create table PHOTO ( ID NUMBER, P_NAME VARCHAR2(30), P_URL VARCHAR2(50), P_ALBUMID NUMBER(30) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255 storage ( initial 64 minextents 1 maxextents unlimited ); -- Create/Recreate primary, unique and foreign key constraints alter table PHOTO add constraint ALB_ID foreign key (P_ALBUMID) references ALBUM (ID); --相片表
好了,所有代码就写完了,切记,需要smartupload.jar包,没有的童鞋可以去下载: