• 大小: 24.13MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-22
  • 语言: Java
  • 标签: java  web  mysql  

资源简介

我的毕业设计 java web paopao音乐在线分享系统 java开发mysql 数据库支持上传下载 在线听音乐 分前后台 有我的开题报告和论文 还有技术文档

资源截图

代码片段和文件信息

package com.action;

import java.io.File;

import java.io.IOException;


import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathxmlApplicationContext;

import com.model.Attachment;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.service.AttachmentService;
//附件的action
public class AttachmentAction extends ActionSupport {
/**
 * 
 */
private static final long serialVersionUID = 1L;
ApplicationContext context = new ClassPathxmlApplicationContext(“beans.xml“);
AttachmentService as = (AttachmentService) context.getBean(“attachmentService“);
 private File uploadify;
 
 private String uploadifyFileName;
    private  Attachment attachment;
    

   

public File getUploadify() {
return uploadify;
}


public void setUploadify(File uploadify) {
this.uploadify = uploadify;
}


public String getUploadifyFileName() {
return uploadifyFileName;
}


public void setUploadifyFileName(String uploadifyFileName) {
this.uploadifyFileName = uploadifyFileName;
}


public Attachment getAttachment() {
return attachment;
}


public void setAttachment(Attachment attachment) {
this.attachment = attachment;
}


public  String uploadFile() throws Exception{
int i=0;
   String realpath = ServletActionContext.getServletContext().getRealPath(“/music“);
        //D:\apache-tomcat-6.0.18\webapps\struts2_upload\music
        System.out.println(“realpath: “+realpath);
        if (uploadify != null) {
            File savefile = new File(new File(realpath) uploadifyFileName);
            if (!savefile.getParentFile().exists())
                savefile.getParentFile().mkdirs();
            try {
FileUtils.copyFile(uploadify savefile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
            ActionContext.getContext().put(“message“ “文件上传成功“);
            Attachment att=new Attachment();
            att.setAttachmentname(uploadifyFileName);
            att.setAttachmentpath(“http://localhost:8080/Music/music/“+uploadifyFileName);
           att.setAttachmentsize(uploadify.length()/1024);
           i=as.addAttachment(att);
            
        }
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding(“utf-8“);
       
        //这个地方不能少,否则前台得不到上传的结果  
        response.getWriter().print(i);

return NONE;
}



}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-24 14:19  20115007赵俊\
     目录           0  2014-04-10 15:48  20115007赵俊\Music\
     文件        5438  2014-03-26 09:32  20115007赵俊\music.sql
     文件        1193  2014-04-09 20:58  20115007赵俊\Music\.classpath
     文件        1404  2014-03-17 09:36  20115007赵俊\Music\.project
     目录           0  2014-04-09 20:54  20115007赵俊\Music\.settings\
     文件         522  2014-03-05 14:46  20115007赵俊\Music\.settings\.jsdtscope
     文件         128  2014-03-06 22:26  20115007赵俊\Music\.settings\com.genuitec.eclipse.core.prefs
     文件         239  2014-04-10 16:24  20115007赵俊\Music\.settings\org.eclipse.core.resources.prefs
     文件         364  2014-03-05 14:46  20115007赵俊\Music\.settings\org.eclipse.jdt.core.prefs
     文件         466  2014-03-05 14:46  20115007赵俊\Music\.settings\org.eclipse.wst.common.component
     文件         414  2014-03-05 14:46  20115007赵俊\Music\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2014-03-05 14:46  20115007赵俊\Music\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2014-03-05 14:46  20115007赵俊\Music\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2014-03-25 01:16  20115007赵俊\Music\build\
     目录           0  2014-04-10 16:24  20115007赵俊\Music\build\classes\
     文件        1773  2014-04-09 21:04  20115007赵俊\Music\build\classes\beans.xml
     目录           0  2014-04-09 20:58  20115007赵俊\Music\build\classes\com\
     目录           0  2014-04-09 20:58  20115007赵俊\Music\build\classes\com\action\
     文件        3778  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\action\AttachmentAction.class
     文件        4301  2014-04-10 16:22  20115007赵俊\Music\build\classes\com\action\CommentAction.class
     文件        1474  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\action\FileAction.class
     文件        3179  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\action\MusicTypeAction.class
     文件        4542  2014-04-09 20:58  20115007赵俊\Music\build\classes\com\action\Useraction.class
     文件        3791  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\action\UserMusicAction.class
     目录           0  2014-04-09 20:58  20115007赵俊\Music\build\classes\com\dao\
     文件         519  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\dao\AttachmentDAO.class
     文件         268  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\dao\CommentDAO.class
     目录           0  2014-04-09 20:58  20115007赵俊\Music\build\classes\com\dao\impl\
     文件        3170  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\dao\impl\AttachmentDaoimpl.class
     文件        1795  2014-04-10 16:24  20115007赵俊\Music\build\classes\com\dao\impl\CommentDaoImpl.class
............此处省略3085个文件信息

评论

共有 条评论