资源简介
内有sql文件 自己创建数据库 表,需要配置七牛的相关属性
代码片段和文件信息
package com.shiyanlou.photo.action;
import java.io.IOException;
import java.util.Date;
import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import com.shiyanlou.photo.domain.Image;
import com.shiyanlou.photo.domain.User;
import com.shiyanlou.photo.service.ImageService;
/**
* 图片控制器
* @author www.shiyanlou.com
*
*/
@WebServlet(value = “/ImageAction“)
@MultipartConfig
public class ImageAction extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“utf-8“);
response.setCharacterEncoding(“utf-8“);
response.setContentType(“text/html;charset=utf-8“);
Integer type = Integer.valueOf(request.getParameter(“type“));
ImageService imageService = new ImageService();
if (type == 1) { //上传图片
String imageName = request.getParameter(“image_name“);
Part image = request.getPart(“image“);
Image img = new Image();
img.setDate(new Date());
img.setName(imageName);
img.setUser((User) request.getSession().getAttribute(“user“));
img.setUrl(img.getUser().getUsername() + “/“ + UUID.randomUUID());
imageService.addImage(img image.getInputStream());
request.getSession().setAttribute(“imageList“ imageService.getByUserId(img.getUser().getId()));
response.sendRedirect(request.getContextPath() + “/home.jsp“);
} else if (type == 2) { //删除图片
String ids = request.getParameter(“ids“);
String urls = request.getParameter(“urls“);
imageService.delByIdsAndUrls(ids urls);
request.getSession().setAttribute(“imageList“ imageService.getByUserId(((User) request.getSession().getAttribute(“user“)).getId()));
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
this.doGet(request response);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-12-29 09:09 photo\
文件 10012 2015-12-29 11:18 photo\.classpath
文件 1038 2015-12-29 09:07 photo\.project
目录 0 2015-12-29 09:10 photo\.settings\
文件 567 2015-12-29 09:07 photo\.settings\.jsdtscope
文件 57 2015-12-29 09:10 photo\.settings\org.eclipse.core.resources.prefs
文件 364 2015-12-29 09:07 photo\.settings\org.eclipse.jdt.core.prefs
文件 467 2015-12-29 09:07 photo\.settings\org.eclipse.wst.common.component
文件 345 2015-12-29 09:07 photo\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2015-12-29 09:07 photo\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-12-29 09:07 photo\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 68 2014-11-07 18:41 photo\README.md
目录 0 2015-12-29 11:17 photo\WebContent\
目录 0 2015-12-29 09:09 photo\WebContent\me
文件 39 2014-11-07 18:41 photo\WebContent\me
目录 0 2015-12-29 09:09 photo\WebContent\WEB-INF\
目录 0 2015-12-29 11:17 photo\WebContent\WEB-INF\lib\
文件 21266 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\com.springsource.javax.servlet.jsp.jstl-1.1.2.jar
文件 398371 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\com.springsource.org.apache.taglibs.standard-1.1.2.jar
文件 232771 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\commons-codec-1.6.jar
文件 62050 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\commons-logging-1.1.3.jar
文件 21883 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\fluent-hc-4.2.jar
文件 424648 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpclient-4.2.jar
文件 114586 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpclient-cache-4.2.jar
文件 223374 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpcore-4.2.1.jar
文件 30683 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpcore-ab-4.2.1.jar
文件 285437 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpcore-nio-4.2.1.jar
文件 26591 2014-11-07 18:41 photo\WebContent\WEB-INF\lib\httpmime-4.2.jar
目录 0 2015-12-29 11:17 photo\WebContent\WEB-INF\lib\kind\
文件 62983 2015-12-28 15:51 photo\WebContent\WEB-INF\lib\kind\activation-2.2.1.jar
文件 445288 2015-12-28 15:51 photo\WebContent\WEB-INF\lib\kind\antlr-2.7.7.jar
............此处省略397个文件信息
- 上一篇:java项目开发实战密码(代码)
- 下一篇:仿QQ+webso框架·开源
评论
共有 条评论