導航:首頁 > 編程語言 > 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框架下載文件相關的資料

熱點內容
主力散戶派發源碼 瀏覽:663
linux如何修復伺服器時間 瀏覽:55
榮縣優途網約車app叫什麼 瀏覽:472
百姓網app截圖是什麼意思 瀏覽:222
php如何嵌入html 瀏覽:809
解壓專家怎麼傳輸 瀏覽:743
如何共享伺服器的網路連接 瀏覽:132
程序員簡易表白代碼 瀏覽:166
什麼是無線加密狗 瀏覽:62
國家反詐中心app為什麼會彈出 瀏覽:67
cad壓縮圖列印 瀏覽:102
網頁打開速度與伺服器有什麼關系 瀏覽:863
android開發技術文檔 瀏覽:65
32單片機寫程序 瀏覽:49
三星雙清無命令 瀏覽:837
漢壽小程序源碼 瀏覽:344
易助erp雲伺服器 瀏覽:532
修改本地賬戶管理員文件夾 瀏覽:419
python爬蟲工程師招聘 瀏覽:285
小鵬p7聽音樂哪個app好 瀏覽:358