使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx

上传人:b****6 文档编号:21316567 上传时间:2023-01-29 格式:DOCX 页数:18 大小:85.46KB
下载 相关 举报
使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx_第1页
第1页 / 共18页
使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx_第2页
第2页 / 共18页
使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx_第3页
第3页 / 共18页
使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx_第4页
第4页 / 共18页
使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx

《使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx(18页珍藏版)》请在冰豆网上搜索。

使用ckeditor struts2 freemaker的图片上传Word格式文档下载.docx

stylesheet"

text/css"

href="

ckeditor/contents.css"

/>

8. 

style 

9. 

10. 

font-family:

宋体"

;

11. 

font-size:

14px 

12. 

13. 

/style>

14. 

15.<

title>

CKEditor 

Testing<

/title>

16.<

/head>

17.<

body>

18. 

19. 

form 

id="

form1"

name="

method="

post"

action="

ck"

20. 

table 

width="

650"

height="

400"

border="

0"

align="

center"

21. 

tr>

22. 

23. 

td>

textarea 

cols="

80"

content"

/textarea>

24. 

25. 

CKEDITOR.replace('

content'

addUploadButton(this));

26. 

27. 

function 

addUploadButton(editor) 

28. 

CKEDITOR.on('

dialogDefinition'

 

function( 

ev 

){ 

29. 

var 

dialogName 

ev.data.name;

30. 

dialogDefinition 

ev.data.definition;

31. 

if 

( 

== 

'

image'

32. 

infoTab 

dialogDefinition.getContents( 

info'

);

33. 

infoTab.add({ 

34. 

type 

:

button'

 

35. 

id 

upload_image'

36. 

align 

center'

37. 

label 

上传'

38. 

onClick 

evt 

39. 

thisthisDialog 

this.getDialog();

40. 

txtUrlObj 

thisDialog.getContentElement('

txtUrl'

41. 

txtUrlId 

txtUrlObj.getInputElement().$.id;

42. 

43. 

addUploadImage(txtUrlId);

44. 

45. 

}, 

browse'

//place 

front 

of 

the 

browser 

button 

46. 

47. 

});

48. 

49. 

50. 

51. 

addUploadImage(theURLElementId) 

52. 

//var 

uploadUrl 

uploadFiles.jsp"

53. 

imgUrl 

window.open('

uploadFiles.jsp'

'

_blank'

54. 

window.showModalDialog("

55. 

alert(imgUrl);

56. 

urlObj 

document.getElementById(theURLElementId);

57. 

// 

urlObj.value 

imgUrl;

58. 

urlObj.fireEvent("

onchange"

59. 

60. 

61. 

/td>

62. 

/tr>

63. 

64. 

65. 

input 

submit"

Submit"

value="

提交"

66. 

reset"

Reset"

重置"

67. 

68. 

/table>

69. 

/form>

70. 

71.<

/body>

72.<

/html>

DOCTYPEhtmlPUBLIC"

-//W3C//DTDHTML4.01Transitional//EN"

"

metahttp-equiv="

content="

charset=UTF-8"

scripttype="

src="

<

linkrel="

type="

href="

styletype="

*{

font-family:

font-size:

14px

}

CKEditorTesting<

formid="

name="

method="

action="

tablewidth="

height="

border="

align="

textareacols="

id="

CKEDITOR.replace('

functionaddUploadButton(editor){

CKEDITOR.on('

function(ev){

vardialogName=ev.data.name;

vardialogDefinition=ev.data.definition;

if(dialogName=='

){

varinfoTab=dialogDefinition.getContents('

);

infoTab.add({

type:

'

id:

align:

label:

onClick:

function(evt){

varthisDialog=this.getDialog();

vartxtUrlObj=thisDialog.getContentElement('

'

vartxtUrlId=txtUrlObj.getInputElement().$.id;

addUploadImage(txtUrlId);

}

},'

//placefrontofthebrowserbutton

});

functionaddUploadImage(theURLElementId){

//varuploadUrl="

//varimgUrl=window.open('

varimgUrl=window.showModalDialog("

alert(imgUrl);

//varurlObj=document.getElementById(theURLElementId);

//urlObj.value=imgUrl;

//urlObj.fireEvent("

}

inputtype="

value="

/>

再写struts.xml文件:

Xml代码

?

xml 

version="

1.0"

encoding="

UTF-8"

struts 

PUBLIC 

3. 

-//Apache 

Software 

Foundation//DTD 

Struts 

Configuration 

2.0//EN"

4. 

//struts.apache.org/dtds/struts-2.0.dtd"

struts>

-- 

constant 

struts.devMode"

true"

-->

package 

index"

extends="

struts-default"

action 

class="

com.lee.action.CKAction"

result 

success"

freemarker"

freemarker/ck.ftl<

/result>

/action>

15. 

16. 

name 

="

fileUpload"

class 

com.lee.action.MyUploadAction"

17. 

interceptor-ref 

fileUploadStack"

/testStrutsView.jsp 

/result 

/action 

com.lee.action.MyUploadAction2"

uploadFiles.jsp 

/package>

29.<

/struts>

xmlversion="

encoding="

?

DOCTYPEstrutsPUBLIC

-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"

<

--

constantname="

-->

packagename="

extends="

actionname="

class="

>

resultname="

actionname="

class="

interceptor-refname="

resultname="

/testStrutsView.jsp<

/result>

/action>

uploadFiles.jsp<

写Action类:

Java代码

1.package 

com.lee.action;

2. 

3.import 

java.io.BufferedInputStream;

4.import 

java.io.BufferedOutputStream;

5.import 

java.io.File;

6.import 

java.io.FileInputStream;

7.import 

java.io.FileOutputStream;

8.import 

java.io.InputStream;

9.import 

java.io.OutputStream;

10.import 

java.util.Date;

12.import 

javax.servlet.http.HttpServletRequest;

14.import 

org.apache.struts2.ServletActionContext;

16.import 

com.opensymphony.xwork2.Action;

17.import 

com.opensymphony.xwork2.ActionSupport;

19.public 

MyUploadAction2 

extends 

ActionSupport 

private 

static 

final 

long 

serialVersionUID 

572146812454l 

int 

BUFFER_SIZE 

16 

1024 

File 

myFile;

String 

contentType;

fileName;

imageFileName;

pagePath;

public 

getPagePath() 

return 

void 

setPagePath(String 

pagePath) 

this.pagePath 

setMyFileContentType(String 

contentType) 

this 

.contentType 

setMyFileFileName(String 

fileName) 

.fileName 

setMyFile(File 

myFile) 

.myFile 

getImageFileName() 

copy(File 

src,File 

dst) 

try 

InputStream 

in 

null 

OutputStream 

out 

new 

BufferedInputStream( 

FileInputStream(src), 

BUFFER_SIZE);

BufferedOutputStream( 

FileOutputStream(dst), 

byte 

[] 

buffer 

[BUFFER_SIZE];

while 

(in.re

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1