麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > JSP > 正文

jsp實(shí)現(xiàn)仿QQ空間新建多個(gè)相冊名稱并向相冊中添加照片功能

2024-09-05 00:22:58
字體:
供稿:網(wǎng)友

工具:Eclipse,Oracle,smartupload.jar;語言:jsp,Java;數(shù)據(jù)存儲(chǔ):Oracle。

實(shí)現(xiàn)功能介紹:

主要是新建相冊,可以建多個(gè)相冊,在相冊中添加多張照片,刪除照片,刪除相冊,當(dāng)相冊下有照片時(shí)先刪除照片才能刪除相冊。

因?yàn)槊總€(gè)相冊和照片要有所屬人,所以順帶有登錄功能。

聲明:只是后端實(shí)現(xiàn)代碼,前臺(tái)無任何樣式,代碼測試可行,僅供參考。

代碼:

數(shù)據(jù)庫連接幫助類:

public class JDBCHelper {  public static final String DRIVER = "oracle.jdbc.driver.OracleDriver";  public static final String URL = "jdbc:oracle:thin:@localhost:1521:xxxx";  public static final String DBNAME = "scott";  public static final String PASSWORD = "xxxx";  public static Connection getConn() throws Exception{  Class.forName(DRIVER);  Connection conn = DriverManager.getConnection(URL, DBNAME, PASSWORD);  return conn;  } } 

圖片上傳時(shí),要修改圖片名稱,防止上傳重名圖片將上一張覆蓋,這里的做法是將圖片名改為由用戶ID和精確到毫秒的時(shí)間組成,修改圖片名的幫助類:

public class PhotoName {  private String ip;  public PhotoName(String ip) {  super();  this.ip = ip;  }  public String getIp() {  return ip;  }  public void setIp(String ip) {  this.ip = ip;  }  public String getTime(){  Date date = new Date();  DateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");  return df.format(date);  }  public String getPhotoName(){  return this.ip + this.getTime();  } } 

實(shí)現(xiàn)所有這些的接口類:

public interface UpDAO {  /**  * 創(chuàng)建相冊名稱  *  */  public int creAlbum(AlbumPOJO ap);  /**  *顯示所創(chuàng)建的所有相冊名稱  */  public List<AlbumPOJO> findAllAlbum(int id);  public List<PhotoPOJO> findAllPhoto(int id);  /**  * 上傳照片  */  public int upPhoto(PhotoPOJO pp);  /**  * 刪除相冊  * @param id 相冊id  * @return  */  public int delAlbum(int id);  /**  * 刪除照片  * @param id 照片id  * @return  */  public int delPhoto(int id);  /**  * 登錄  * @param username  * @param password  * @return  */  public UserPOJO login(String username,String password); } 

接口的具體實(shí)現(xiàn)類:

public class UpDAOImpl implements UpDAO {  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#creAlbum(cn.jvsun.POJO.AlbumPOJO)  * 創(chuàng)建相冊名稱  */  public int creAlbum(AlbumPOJO ap) {  int albumNum=this.getAlbumNum();  Connection conn = null;  PreparedStatement pstate = null;  try {   conn=JDBCHelper.getConn();   conn.setAutoCommit(false);   String sql="insert into album(id,a_name,user_id)values(?,?,?)";   pstate = conn.prepareStatement(sql);   pstate.setInt(1, albumNum);   pstate.setString(2,ap.getA_name());   pstate.setInt(3, ap.getUser_id());   pstate.execute();   conn.commit();  } catch (Exception e) {   e.printStackTrace();   try {   conn.rollback();//出問題就撤回,全不提交   } catch (SQLException e1) {   e1.printStackTrace();   }  }finally{   try {   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return albumNum;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#upPhoto(java.lang.String, java.lang.String, int)  * 上傳照片  */  public int upPhoto(PhotoPOJO pp) {  int pNum=this.getPhotoNum();  Connection conn = null;  PreparedStatement pstate = null;  try {   conn=JDBCHelper.getConn();   conn.setAutoCommit(false);   String sql="insert into photo(id,p_name,p_url,p_albumid)values(?,?,?,?)";   pstate = conn.prepareStatement(sql);   pstate.setInt(1, pNum);   pstate.setString(2,pp.getP_name());   pstate.setString(3, pp.getP_url());   pstate.setInt(4, pp.getP_albumId());   pstate.execute();   conn.commit();  } catch (Exception e) {   e.printStackTrace();   try {   conn.rollback();//出問題就撤回,全不提交   } catch (SQLException e1) {   e1.printStackTrace();   }  }finally{   try {   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return pNum;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#delAlbum(int)  * 刪除相冊  */  public int delAlbum(int id) {  int result=0;  Connection conn = null;  PreparedStatement pstate = null;  String sql="delete from album where id="+id+"";  try {   conn=JDBCHelper.getConn();   pstate = conn.prepareStatement(sql);   result=pstate.executeUpdate();  } catch (SQLException e) {   e.printStackTrace();  } catch (Exception e) {   // TODO Auto-generated catch block   e.printStackTrace();  }finally{   try {   pstate.close();   conn.close();   } catch (SQLException e) {   // TODO Auto-generated catch block   e.printStackTrace();   }  }  return result;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#delPhoto(int)  * 刪除照片  */  public int delPhoto(int id) {  int result=0;  Connection conn = null;  PreparedStatement pstate = null;  String sql="delete from photo where id="+id+"";  try {   conn=JDBCHelper.getConn();   pstate = conn.prepareStatement(sql);   result=pstate.executeUpdate();  } catch (SQLException e) {   e.printStackTrace();  } catch (Exception e) {   // TODO Auto-generated catch block   e.printStackTrace();  }finally{   try {   pstate.close();   conn.close();   } catch (SQLException e) {   // TODO Auto-generated catch block   e.printStackTrace();   }  }  return result;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#login(java.lang.String, java.lang.String)  * 用戶登錄  */  public UserPOJO login(String username, String password) {  UserPOJO user=null;  Connection conn = null;  PreparedStatement pstate = null;  ResultSet res = null;  try {   conn=JDBCHelper.getConn();   String sql="select id,username from userinfo where username=? and password=?";   pstate = conn.prepareStatement(sql);   pstate.setString(1, username);   pstate.setString(2, password);   res = pstate.executeQuery();   while(res.next()){   user=new UserPOJO(res.getInt(1),username,null);   }  } catch (Exception e) {   e.printStackTrace();  }finally{   try {   res.close();   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return user;  }  /**  * 相冊序列號  */  public int getAlbumNum(){  int albumNum=-1;  Connection conn = null;  PreparedStatement pstate = null;  ResultSet res = null;  try {   conn=JDBCHelper.getConn();   String sql="select aid.nextval from dual";   pstate=conn.prepareStatement(sql);   res=pstate.executeQuery();   while(res.next()){   albumNum=res.getInt(1);   }  } catch (Exception e) {   e.printStackTrace();  }finally{   try {   res.close();   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return albumNum;  }  /**  *照片序列號  */  public int getPhotoNum(){  int photoNum=-1;  Connection conn = null;  PreparedStatement pstate = null;  ResultSet res = null;  try {   conn=JDBCHelper.getConn();   String sql="select pid.nextval from dual";   pstate=conn.prepareStatement(sql);   res=pstate.executeQuery();   while(res.next()){   photoNum=res.getInt(1);   }  } catch (Exception e) {   e.printStackTrace();  }finally{   try {   res.close();   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return photoNum;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#findAll()  * 顯示所創(chuàng)建的相冊名  */  public List<AlbumPOJO> findAllAlbum(int id) {  List<AlbumPOJO> list= new ArrayList<AlbumPOJO>();  Connection conn = null;  PreparedStatement pstate = null;  ResultSet res = null;  try {   conn=JDBCHelper.getConn();   String sql="select id,a_name,user_id from album where user_id=?";   pstate = conn.prepareStatement(sql);   pstate.setInt(1, id);   res = pstate.executeQuery();   while(res.next()){   AlbumPOJO ap=new AlbumPOJO(res.getInt(1),res.getString(2),res.getInt(3));   list.add(ap);   }  } catch (Exception e) {   e.printStackTrace();  }finally{   try {   res.close();   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return list;  }  /* (non-Javadoc)  * @see cn.jvsun.DAO.UpDAO#findAllPhoto(int)  * 顯示照片  */  public List<PhotoPOJO> findAllPhoto(int aid) {  List<PhotoPOJO> list= new ArrayList<PhotoPOJO>();  Connection conn = null;  PreparedStatement pstate = null;  ResultSet res = null;  try {   conn=JDBCHelper.getConn();   String sql="select id,p_name,p_url from photo where P_ALBUMID=?";   pstate = conn.prepareStatement(sql);   pstate.setInt(1, aid);   res = pstate.executeQuery();   while(res.next()){   PhotoPOJO pojo=new PhotoPOJO(res.getInt(1),res.getString(2),res.getString(3), aid);   list.add(pojo);   }  } catch (Exception e) {   e.printStackTrace();  }finally{   try {   res.close();   pstate.close();   conn.close();   } catch (SQLException e) {   e.printStackTrace();   }  }  return list;  } } 

用戶,相冊,照片三個(gè)POJO類:

/** * 用戶實(shí)體類  *  */ public class UserPOJO implements Serializable{  private static final long serialVersionUID = 7554548269035753256L;  private int id;  private String username;  private String password;  public int getId() {  return id;  }  public void setId(int id) {  this.id = id;  }  public String getUsername() {  return username;  }  public void setUsername(String username) {  this.username = username;  }  public String getPassword() {  return password;  }  public void setPassword(String password) {  this.password = password;  }  public UserPOJO(int id, String username, String password) {  super();  this.id = id;  this.username = username;  this.password = password;  }  public UserPOJO(String username, String password) {  this.username = username;  this.password = password;  }  public UserPOJO() {  super();  // TODO Auto-generated constructor stub  } } 
/**  * 相冊實(shí)體類  *  */ public class AlbumPOJO implements Serializable{  private int id;  private String a_name;  private int user_id;  public int getId() {  return id;  }  public void setId(int id) {  this.id = id;  }  public String getA_name() {  return a_name;  }  public void setA_name(String a_name) {  this.a_name = a_name;  }  public int getUser_id() {  return user_id;  }  public void setUser_id(int user_id) {  this.user_id = user_id;  }  public AlbumPOJO(int id, String a_name, int user_id) {  super();  this.id = id;  this.a_name = a_name;  this.user_id = user_id;  }  public AlbumPOJO(String a_name, int user_id) {  this.a_name = a_name;  this.user_id = user_id;  }  public AlbumPOJO() {  super();  // TODO Auto-generated constructor stub  } } 
/**  *照片實(shí)體類  *  */ public class PhotoPOJO implements Serializable{  private static final long serialVersionUID = 5937149639009957458L;  private int id;  private String p_name;  private String p_url;  private int p_albumId;  public int getId() {  return id;  }  public void setId(int id) {  this.id = id;  }  public String getP_name() {  return p_name;  }  public void setP_name(String p_name) {  this.p_name = p_name;  }  public String getP_url() {  return p_url;  }  public void setP_url(String p_url) {  this.p_url = p_url;  }  public int getP_albumId() {  return p_albumId;  }  public void setP_albumId(int p_albumId) {  this.p_albumId = p_albumId;  }  public PhotoPOJO(int id, String p_name, String p_url, int p_albumId) {  super();  this.id = id;  this.p_name = p_name;  this.p_url = p_url;  this.p_albumId = p_albumId;  }  public PhotoPOJO(String p_name, String p_url, int p_albumId) {  this.p_name = p_name;  this.p_url = p_url;  this.p_albumId = p_albumId;  }  public PhotoPOJO() {  super();  // TODO Auto-generated constructor stub  } } 

login.jsp實(shí)現(xiàn)登錄

<%@ 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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <title>login</title>  </head>  <body>  <%  request.setCharacterEncoding("utf-8");  String action=request.getParameter("action");  UpDAO ud=new UpDAOImpl();  String username=request.getParameter("username");  String password=request.getParameter("password");  UserPOJO pojo=ud.login(username, password);  if("log".equals(action)){  if(pojo==null){   %>   <h1>登錄失敗</h1>   <%  }else{   request.getSession().setAttribute("username", username);   request.getSession().setAttribute("userid", pojo.getId());   response.sendRedirect("index.jsp");  }  }  %>  <form action="login.jsp?action=log" method="post">  <input type="text" name="username" placeholder="請輸入用戶名"/>  <input type="password" name="password" placeholder="請輸入密碼"/>  <input type="submit"/>  </form>  </body> </html> 

index.jsp實(shí)現(xiàn)顯示相冊

代碼如下:

<%@ 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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <title>person message</title>  </head>  <body>  <center>相冊界面</center>  當(dāng)前用戶:<%=request.getSession().getAttribute("username")%> <br>  <a href="cre.jsp" rel="external nofollow" >去創(chuàng)建相冊</a><br>  我的所有相冊:<br>  <%  int userid=(Integer)request.getSession().getAttribute("userid");  UpDAO dao=new UpDAOImpl();  List<AlbumPOJO> list=dao.findAllAlbum(userid);  for(AlbumPOJO pojo:list){  %>  <tr>  <a>相冊id:</a><td><%=pojo.getId() %></td>  <a>相冊名稱:</a><td><%=pojo.getA_name() %></td>  <a>創(chuàng)建者id:</a><td><%=pojo.getUser_id() %></td>  <td><a href="up.jsp?aid=<%=pojo.getId() %>" rel="external nofollow" >添加照片</a></td>  <td><a href="show.jsp?phid=<%=pojo.getId() %>" rel="external nofollow" >查看照片</a></td>  <td><a href="del.jsp?aid=<%=pojo.getId() %>" rel="external nofollow" >刪除相冊</a></td>  </tr><br>  <%  }  %>  </body> </html> 

cre.jsp創(chuàng)建相冊

<%@ 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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <title>up photo</title>  </head>  <body>  <%  request.setCharacterEncoding("utf-8");  String action=request.getParameter("action");  UpDAO ud=new UpDAOImpl();  String toCre=request.getParameter("cre");  int userId=(Integer)request.getSession().getAttribute("userid");  if("cre".equals(action)){  AlbumPOJO ap=new AlbumPOJO(toCre,userId);  int aNum=ud.creAlbum(ap);  if(aNum!=-1){   response.sendRedirect("index.jsp");  }else{   %>   <h1>創(chuàng)建相冊失敗</h1>   <%  }  }  %>  <form action="cre.jsp?action=cre" method="post">  <input type="text" name="cre" placeholder="請輸入您要?jiǎng)?chuàng)建的相冊名稱"/>  <input type="submit" value="確定">  </form>  </body> </html> 

up.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.*" %> <%@ page import="cn.jvsun.tools.*" %> <%@page import="org.lxh.smart.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <title>上傳照片</title>  </head>  <body>  <%  int aid=Integer.parseInt(request.getParameter("aid"));  %>  <form action="upCheck.jsp" method="post" enctype="multipart/form-data">  <input type="hidden" name="aid" value="<%=aid %>"/>  <input type="file" name="photo"/>  <input type="submit" value="確認(rèn)上傳"/>  </form>  </body> </html> 

upCheck.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.*" %> <%@ page import="cn.jvsun.tools.*" %> <%@page import="org.lxh.smart.*" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <title></title>  </head>  <body>  <%  String ip = request.getRemoteAddr();  ip = ip.replaceAll(":","");  PhotoName pn=new PhotoName(ip);  String pName = pn.getPhotoName();//照片名字,是由IP加當(dāng)前時(shí)間組成  SmartUpload smartupload = new SmartUpload();//實(shí)例化上傳操作的對象  //初始化上傳文件  smartupload.initialize(pageContext);  //準(zhǔn)備上傳  smartupload.upload();  int albumId=Integer.parseInt(smartupload.getRequest().getParameter("aid"));  //取得文件的后綴  String endName = smartupload.getFiles().getFile(0).getFileExt();  //文件保存的路徑  /*String p_url = getServletContext().getRealPath("/")+    "file/"+pName+"."+endName;*/  String p_url="K:/workspace/Xiangce/WebRoot/file/"+pName+"."+endName;  //保存文件  smartupload.getFiles().getFile(0).saveAs(p_url);  UpDAO ad=new UpDAOImpl();  PhotoPOJO pojo=new PhotoPOJO(pName+"."+endName,p_url,albumId);  int photoNum=ad.upPhoto(pojo);  if(photoNum != -1){   request.getSession().setAttribute("phid", albumId);   response.sendRedirect("show.jsp");   } else {  %>  上傳失敗  <%   }  %>  </body> </html> 

show.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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <title>My JSP 'show.jsp' starting page</title>  </head>  <body>  <center>相冊界面</center>  當(dāng)前用戶:<%=request.getSession().getAttribute("username")%> <br>  <%  int phid=(Integer)request.getSession().getAttribute("phid");  UpDAO dao=new UpDAOImpl();  List<PhotoPOJO> list=dao.findAllPhoto(phid);  for(PhotoPOJO pojo:list){  %>  <tr>  <a>照片id:</a><td><%=pojo.getId() %></td><br>  <a>照片名稱:</a><td><%=pojo.getP_name() %></td><br>  <a>照片路徑:</a><td><%=pojo.getP_url() %></td><br>  <a>照片所屬相冊名稱:</a><td><%=pojo.getP_albumId() %></td><br>  <td><img src="<%=path%>/file/<%=pojo.getP_name() %>" width="100" height="100"/></td>  <a href="photo_del.jsp?pid=<%=pojo.getId() %>" rel="external nofollow" >刪除照片:</a></td><br>  </tr><br>  <%} %>  </body> </html> 

photo_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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <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('出錯(cuò)了');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+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >  <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> 

數(shù)據(jù)庫的建表語句:

-- 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包,沒有的童鞋可以去下載:

smartuploadjar包

以上所述是小編給大家介紹的jsp實(shí)現(xiàn)仿QQ空間新建多個(gè)相冊名稱并向相冊中添加照片功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對VeVb武林網(wǎng)網(wǎng)站的支持!

 

注:相關(guān)教程知識閱讀請移步到JSP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 夜夜夜操操操 | 草久在线观看视频 | 成人情欲视频在线看免费 | 亚洲精中文字幕二区三区 | 亚洲一二区精品 | 久久国产精品免费视频 | 日韩中文字幕一区二区三区 | 久久精品欧美电影 | 激情在线视频 | 久久久午夜电影 | 免费午夜网站 | 真人一级毛片免费 | 国产精品免费久久久久 | 国产精品久久久久久婷婷天堂 | 午夜精品影院 | 男女无遮挡羞羞视频 | 狠狠干天天操 | 欧美日韩免费一区 | 视频一区二区国产 | 黄色av电影在线 | 黄色片免费在线播放 | 欧美激情天堂 | 久久精品视频在线看99 | 嫩草91在线 | 日韩毛片一区二区三区 | 可以免费看的av | 伦一区二区三区中文字幕v亚洲 | 成人在线不卡 | 亚洲精品成人av在线 | 久草在线视频在线 | 久久久久久久久久久高潮一区二区 | 一级一级一级毛片 | 精品二区在线观看 | 国产一级免费不卡 | 成人精品久久 | 国产黄网 | 中文字幕1区2区 | 黄色毛片免费看 | 男人久久天堂 | 亚洲片在线观看 | 欧美大电影免费观看 |