導航:首頁 > 文檔加密 > strutspdf

strutspdf

發布時間:2022-08-19 09:23:44

① 網頁打開pdf後,點擊保存,保存的文件名是struts-config.xml配置的action

你解決了么···;
我們沒有解決

② 哪位有「struts2權威指南完整版pdf」下載地址的,麻煩給個...

給個郵箱啊

③ 誰有比較好的Struts2的入門書籍CHM 或者PDF的都可以

已發送,strtus2權威指南。[email protected]

④ 基於struts2+hibernate+spring實用開發指南pdf(高洪岩)

&app=zd 有下載,自己參考下。

java中怎麼利用struts2上傳多個pdf文件

通過3種方式模擬多個文件上傳
第一種方式
package com.ljq.action;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UploadAction extends ActionSupport{
private File[] image; //上傳的文件
private String[] imageFileName; //文件名稱
private String[] imageContentType; //文件類型
public String execute() throws Exception {
ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
String realpath = ServletActionContext.getServletContext().getRealPath("/images");
System.out.println(realpath);
if (image != null) {
File savedir=new File(realpath);
if(!savedir.getParentFile().exists())
savedir.getParentFile().mkdirs();
for(int i=0;i<image.length;i++){
File savefile = new File(savedir, imageFileName[i]);
FileUtils.File(image[i], savefile);
}
ActionContext.getContext().put("message", "文件上傳成功");
}
return "success";
}
public File[] getImage() {
return image;
}
public void setImage(File[] image) {
this.image = image;
}
public String[] getImageContentType() {
return imageContentType;
}
public void setImageContentType(String[] imageContentType) {
this.imageContentType = imageContentType;
}
public String[] getImageFileName() {
return imageFileName;
}
public void setImageFileName(String[] imageFileName) {
this.imageFileName = imageFileName;
}
}
第二種方式
package com.ljq.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
* 使用數組上傳多個文件
*
* @author ljq
*
*/
@SuppressWarnings("serial")
public class UploadAction2 extends ActionSupport{
private File[] image; //上傳的文件
private String[] imageFileName; //文件名稱
private String[] imageContentType; //文件類型
private String savePath;
@Override
public String execute() throws Exception {
ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
//取得需要上傳的文件數組
File[] files = getImage();
if (files !=null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
//建立上傳文件的輸出流, getImageFileName()[i]
System.out.println(getSavePath() + "\\" + getImageFileName()[i]);
FileOutputStream fos = new FileOutputStream(getSavePath() + "\\" + getImageFileName()[i]);
//建立上傳文件的輸入流
FileInputStream fis = new FileInputStream(files[i]);
byte[] buffer = new byte[1024];
int len = 0;
while ((len=fis.read(buffer))>0) {
fos.write(buffer, 0, len);
}
fos.close();
fis.close();
}
}
return SUCCESS;
}
public File[] getImage() {
return image;
}
public void setImage(File[] image) {
this.image = image;
}
public String[] getImageFileName() {
return imageFileName;
}
public void setImageFileName(String[] imageFileName) {
this.imageFileName = imageFileName;
}
public String[] getImageContentType() {
return imageContentType;
}
public void setImageContentType(String[] imageContentType) {
this.imageContentType = imageContentType;
}
/**
* 返回上傳文件保存的位置
*
* @return
* @throws Exception
*/
public String getSavePath() throws Exception {
return ServletActionContext.getServletContext().getRealPath(savePath);
}
public void setSavePath(String savePath) {
this.savePath = savePath;
}
}
第三種方式
package com.ljq.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
* 使用List上傳多個文件
*
* @author ljq
*
*/
@SuppressWarnings("serial")
public class UploadAction3 extends ActionSupport {
private List<File> image; // 上傳的文件
private List<String> imageFileName; // 文件名稱
private List<String> imageContentType; // 文件類型
private String savePath;
@Override
public String execute() throws Exception {
ServletActionContext.getRequest().setCharacterEncoding("UTF-8");
// 取得需要上傳的文件數組
List<File> files = getImage();
if (files != null && files.size() > 0) {
for (int i = 0; i < files.size(); i++) {
FileOutputStream fos = new FileOutputStream(getSavePath() + "\\" + getImageFileName().get(i));
FileInputStream fis = new FileInputStream(files.get(i));
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
fis.close();
fos.close();
}
}
return SUCCESS;
}
public List<File> getImage() {
return image;
}
public void setImage(List<File> image) {
this.image = image;
}
public List<String> getImageFileName() {
return imageFileName;
}
public void setImageFileName(List<String> imageFileName) {
this.imageFileName = imageFileName;
}
public List<String> getImageContentType() {
return imageContentType;
}
public void setImageContentType(List<String> imageContentType) {
this.imageContentType = imageContentType;
}
/**
* 返回上傳文件保存的位置
*
* @return
* @throws Exception
*/
public String getSavePath() throws Exception {
return ServletActionContext.getServletContext().getRealPath(savePath);
}
public void setSavePath(String savePath) {
this.savePath = savePath;
}
}
struts.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 該屬性指定需要Struts2處理的請求後綴,該屬性的默認值是action,即所有匹配*.action的請求都由Struts2處理。
如果用戶需要指定多個請求後綴,則多個後綴之間以英文逗號(,)隔開。 -->
<constant name="struts.action.extension" value="do" />
<!-- 設置瀏覽器是否緩存靜態內容,默認值為true(生產環境下使用),開發階段最好關閉 -->
<constant name="struts.serve.static.browserCache" value="false" />
<!-- 當struts的配置文件修改後,系統是否自動重新載入該文件,默認值為false(生產環境下使用),開發階段最好打開 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 開發模式下使用,這樣可以列印出更詳細的錯誤信息 -->
<constant name="struts.devMode" value="true" />
<!-- 默認的視圖主題 -->
<constant name="struts.ui.theme" value="simple" />
<!--<constant name="struts.objectFactory" value="spring" />-->
<!--解決亂碼 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.multipart.maxSize" value="10701096"/>
<package name="upload" namespace="/upload" extends="struts-default">
<action name="*_upload" class="com.ljq.action.UploadAction" method="{1}">
<result name="success">/WEB-INF/page/message.jsp</result>
</action>
</package>
<package name="upload1" namespace="/upload1" extends="struts-default">
<action name="upload1" class="com.ljq.action.UploadAction2" method="execute">
<!-- 要創建/image文件夾,否則會報找不到文件 -->
<param name="savePath">/image</param>
<result name="success">/WEB-INF/page/message.jsp</result>
</action>
</package>
<package name="upload2" namespace="/upload2" extends="struts-default">
<action name="upload2" class="com.ljq.action.UploadAction3" method="execute">
<!-- 要創建/image文件夾,否則會報找不到文件 -->
<param name="savePath">/image</param>
<result name="success">/WEB-INF/page/message.jsp</result>
</action>
</package>
</struts>
上傳表單頁面upload.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>文件上傳</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
<!-- ${pageContext.request.contextPath}/upload/execute_upload.do -->
<!-- ${pageContext.request.contextPath}/upload1/upload1.do -->
<!-- ${pageContext.request.contextPath}/upload2/upload2.do -->
<!-- -->
<form action="${pageContext.request.contextPath}/upload2/upload2.do" enctype="multipart/form-data" method="post">
文件1:<input type="file" name="image"><br/>
文件2:<input type="file" name="image"><br/>
文件3:<input type="file" name="image"><br/>
<input type="submit" value="上傳" />
</form>
</body>
</html>
顯示頁面message.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'message.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<body>
上傳成功
<br/>
<s:debug></s:debug>
</body>
</html>

⑥ 《Struts2技術內幕》pdf下載在線閱讀全文,求百度網盤雲資源

《Struts2技術內幕》網路網盤pdf最新全集下載:
鏈接:https://pan..com/s/1oeB0hpu0sL7v0uPesIShmQ

?pwd=8nfi 提取碼:8nfi
簡介:本書主要分為三個部分:知識准備篇、核心技術篇和運行主線篇。

知識准備篇(第1章~第3章),除了介紹和分析解讀Struts2的基本環境之外,這一篇的重要任務是幫助讀者梳理Web開發中的主要概念和知識體系。

核心技術篇(第4章~第8章),將對Struts2所依賴的一些核心技術--做出詳細解讀,包括Struts2中所用到的設計模式、xwork的容器實現、OGNL表達式引攀、Xwork框架的控制流和數據流體系等等。

運行主線篇(第9章~第12章),其中主要涉及對Struts2兩大核心運行主線的研究以及對Struts2的擴展機制的分析。

本書的篇章安排有很強的邏輯性,章和章之間互相呼應、互相論證。讀者在閱讀時可以帶著問題到後續章節中去尋找答案,而在每章的小結中,我們會為讀者安排每章的概要性問題,大家可以在此做一個回顧並思考問題的答案,從而起到溫故而知新的效果。

⑦ 如何查看struts上傳的文件

圖片查看<img src="" /> 文本類的,可以直接查看!至於pdf,如果你說的是類似網路文庫的效果,那是有js插件的,這個需要自己寫的。如果不是的話!你這樣<a href="aa.pdf">幫助</a>在火狐瀏覽器上你看到pdf內容,IE瀏覽器被默認為下載。

⑧ 精通Struts2:基於MVC的JavaWeb應用開發實戰 pdf

李剛的那本好.我就買了一本.
可以說李剛的那一套一系列的都不錯.李剛有本輕量級J2EE企業應用實戰.
非常棒,強烈推薦.
我以前買過一本孫衛琴的講基本MVC的開發,不過是STRUTS1.2的
至於PDF版本的,可以去網路文庫搜索下或者去電驢搜索
STRUTS2有本叫權威指南來著,現在應該有STRUTS2.1權威指南,那本可以作為開發人員必備的手冊,不適合入門.

這個嘛,得支持正版,有些書保護得比較好,沒有流傳出PDF的版本.得花錢買網上買了.

閱讀全文

與strutspdf相關的資料

熱點內容
windows的doc命令 瀏覽:463
nfc全加密門禁卡 瀏覽:636
身份信息被加密 瀏覽:482
我的鹽城app怎麼添加不了家庭成員 瀏覽:493
php商城並發 瀏覽:348
熊貓繪畫app怎麼做出大佬的筆刷 瀏覽:603
雲存儲伺服器知識 瀏覽:461
伺服器cpu是什麼指令集 瀏覽:590
糖貓t10怎麼安裝app 瀏覽:992
電腦加密u盤怎麼使用 瀏覽:517
linux如何升級php版本升級 瀏覽:841
二級程序員c語言難度 瀏覽:352
批處理編譯qt 瀏覽:66
鐵友app怎麼查詢機票訂單 瀏覽:197
myeclipselinux破解版 瀏覽:417
批處理命令語法不正確 瀏覽:889
pdf合並成一個pdf在線 瀏覽:383
柱加密區構造要求 瀏覽:515
地板木龍骨標准跟加密區別 瀏覽:151
解壓放鬆的好地方河南 瀏覽:965