导航:首页 > 编程语言 > java框架下载文件

java框架下载文件

发布时间:2022-08-23 06:28:24

java web 框架下载

框架下载,这说法很奇怪,现在主流的框架是SSH(struts2+hibernate+spring),只要下载相关的jar包,具体的这些框架使用方法也是要去学的,可以到电驴上下载马士兵的视频教程

⑵ 用Java的三大框架实现文件的上传下载,求代码啊,最好是分为action,service,serv

package cn.itcast.struts2.demo1;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

/**
* 完成文件上传 (不是解析上传内容,因为上传内容 由fileUpload拦截器负责解析)
*
* @author seawind
*
*/
public class UploadAction extends ActionSupport {
// 接收上传内容
// <input type="file" name="upload" />
private File upload; // 这里变量名 和 页面表单元素 name 属性一致
private String uploadContentType;
private String uploadFileName;

public void setUpload(File upload) {
this.upload = upload;
}

public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}

public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}

@Override
public String execute() throws Exception {
if (upload == null) { // 通过xml配置 required校验器 完成校验
// 没有上传文件
return NONE;
}
// 将上传文件 保存到服务器端
// 源文件 upload
// 目标文件
File destFile = new File(ServletActionContext.getServletContext()
.getRealPath("/upload") + "/" + uploadFileName);
// 文件复制 使用commons-io包 提供 工具类
FileUtils.File(upload, destFile);
return NONE;
}
}
多文件上传
package cn.itcast.struts2.demo1;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

/**
* 支持多文件上传
*
* @author seawind
*
*/
public class MultiUploadAction extends ActionSupport {
// 接收多文件上传参数,提供数组接收就可以了
private File[] upload;
private String[] uploadContentType;
private String[] uploadFileName;

public void setUpload(File[] upload) {
this.upload = upload;
}

public void setUploadContentType(String[] uploadContentType) {
this.uploadContentType = uploadContentType;
}

public void setUploadFileName(String[] uploadFileName) {
this.uploadFileName = uploadFileName;
}

@Override
public String execute() throws Exception {
for (int i = 0; i < upload.length; i++) {
// 循环完成上传
File srcFile = upload[i];
String filename = uploadFileName[i];

// 定义目标文件
File destFile = new File(ServletActionContext.getServletContext()
.getRealPath("/upload" + "/" + filename));
FileUtils.File(srcFile, destFile);
}
return NONE;
}
}

⑶ java爬虫htmluinit框架批量下载文件

我用Jsoup写爬虫,一般遇到html返回没有的内容。但是浏览器显示有的内容。都是分析页面的http请求日志。分析页面JS代码来解决。
1、有些页面元素被隐藏起来了->换selector解决
2、有些数据保存在js/json对象中->截取对应的串,分析解决
3、通过api接口调用->伪造请求获得数据
还有一个终极方法
4、使用phantomjs或者casperjs这种headless浏览器

⑷ 希望您给我发一下用java的ssh框架实现的上传和下载,谢谢啦

晚上回去发给你吧,现在发不了文件.

另外说下,上传下载跟ssh框架好像没多大联系,要说的话,就是struts2上传下载很简单.

⑸ Struts1框架 用Java代码实现文件下载 不弹出下载框 代码:

下载代码:
这里我使用的是SpringMVC,不过它在这里的唯一用途就是用来获取ServletContext对象,这个对象的用途,下面实例中有说明
下载,需要用到两个jar包:commons-fileupload.jar和commons-io.jar

Java代码
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.ServletContextAware;

import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

@Controller
public class FileController implements ServletContextAware{
//Spring这里是通过实现ServletContextAware接口来注入ServletContext对象
private ServletContext servletContext;

@RequestMapping("file/download")
public void fileDownload(HttpServletResponse response){
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
String path = servletContext.getRealPath("/");

//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
response.setContentType("multipart/form-data");
//2.设置文件头:最后一个参数是设置下载文件名(假如我们叫a.pdf)
response.setHeader("Content-Disposition", "attachment;fileName="+"a.pdf");
ServletOutputStream out;
//通过文件路径获得File对象(假如此路径中有一个download.pdf文件)
File file = new File(path + "download/" + "download.pdf");

try {
FileInputStream inputStream = new FileInputStream(file);

//3.通过response获取ServletOutputStream对象(out)
out = response.getOutputStream();

int b = 0;
byte[] buffer = new byte[512];
while (b != -1){
b = inputStream.read(buffer);
//4.写到输出流(out)中
out.write(buffer,0,b);
}
inputStream.close();
out.close();
out.flush();

} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
}

⑹ 请问哪里有java的框架jaxx 下载啊

java.sun.com可以下到,但JAVA不叫框架,叫虚拟机

⑺ java 文件下载能不能支持迅雷struts2框架下的,求大牛指导,谢谢

java 是可以支持迅雷下载的,即使用到了struts框架也是支持的,
下载是以文件流的形式实现的,只要你安装了迅雷,在下载时迅雷就好自动检测到文件流,就会弹出下载框!

⑻ 当今流行的java三大框架下载(struts2.0+hibernate+spring)官方地址

Struts2.0: http://apache.freelamp.com/struts/source/struts-2.0.11.2-src.zip
或者 http://dev.xiaonei.com/apache-mirror/struts/binaries/struts-2.0.12-all.zip
Hibernate3.3: http://nchc.dl.sourceforge.net/sourceforge/hibernate/hibernate-distribution-3.3.1.GA-dist.zip
Spring2.0: http://nchc.dl.sourceforge.net/sourceforge/springframework/spring-framework-2.0.8-with-dependencies.zip

⑼ java spring框架怎么下载怎么搭建怎么使用

下载去官网就可以下载,搭建,有Jar包,写好配置文件就行了,使用两句话能说清楚就不叫框架了。建议看书,或者看教程,或者拿个项目照着写,报错查网络。

⑽ 一般公司的JAVA框架是否可以方便的实现文件的上传与下载、数据的导入和导出的功能

文件的上传于下载、数据的导入和导出在大部门项目中也会遇到,但是这两个功能可能会因为项目的不同导致实现上有一点区别,框架中要做的就是应该抽出其中共有的东西,定义为抽象的东西,以便不同的项目、不同的需求都能很容易的实现该功能。

阅读全文

与java框架下载文件相关的资料

热点内容
修改本地账户管理员文件夹 浏览:416
python爬虫工程师招聘 浏览:283
小鹏p7听音乐哪个app好 浏览:354
linux下的防火墙 浏览:954
凌达压缩机美芝压缩机 浏览:350
php后面代码不执行 浏览:236
微我手机怎样设置应用加密 浏览:202
条件加密 浏览:628
androidstudio设置中文 浏览:641
汽车换压缩机能提升制冷 浏览:628
安卓开发配什么电脑 浏览:607
linux下php模块 浏览:78
阿里云服务器终端在哪里 浏览:147
app纸有什么用 浏览:224
cuteftp命令 浏览:507
最开始的编程语言是什么 浏览:759
at远程命令 浏览:492
云服务器哪家好点 浏览:215
android系统源码阅读 浏览:931
dumpjava分析工具 浏览:680