首页 > 编程知识 正文

网页另存为html格式,servlet实现文件上传

时间:2023-05-03 17:23:45 阅读:141601 作者:3136

关于使用jsp将文件保存到服务器

在html中调用xml数据公共字符串服务(stringtextxml )

stringguestbookpath=getservletcontext ().get realpath (/JSP save.JSP ' );

try{

Java.io.filewriter fw=new Java.io.filewriter (guest book path 'guest book.txt ',true );

Java.io.print writer pw=new Java.io.print writer (fw;

pw.println(TextXML;

pw.close (;

fw.close (;

system.out.println(TextXML;

返回空值;

}

catch(exceptione ) (

//out.println(e.getmessage ) );

}

返回空值;

}

%

————————————335433543——3————————3——3——3333334 -

//上传示例

smartupload upload=new smartupload (;

upload.initialize(pagecontext;

upload.upload (;

for(intI=0; I

com.jspsmart.upload.filenew file=upload.getfile (is ().getfile ) ) I;

if (! newfile.ismissing (

new file.save as (' d :/web src/upload/' new file.getfilename ); //修改你的存储路径

out.println (' field name=' new file.getfield name ) '

();

out.println (' size=' new file.getsize ) )。

();

out.println (' filename=' new file.getfilename ) '

();

out.println (' fileext=' new file.get fileext ) )。

();

out.println (' file pathname=' new file.getfile pathname ) )

();

out.println (' content type=' new file.get content type ) )

();

out.println (' content disp=' new file.get content disp ) )

();

out.println (' type mime=' new file.gettype mime ) '

();

out.println (subtype mime=' new file.getsubtypemime ) '

();

}

}

%

————————————335433543——3————————3——3——3333334 -

有什么不对的! 粘在一起

————————————335433543——3————————3——3——3333334 -

是javascript的错。 在您的onclick方法中调用了savexml方法,但没有定义savexml。 你现在定义的是jsp脚本中的savexml方法。

————————————335433543——3————————3——3——3333334 -

lileinlp (空) onclick当然不能调用jsp脚本中的savexml方法。 页面初始化后,java代码将不再存在。 onclick只能调用js编写的函数

————————————335433543——3————————3——3——3333334 -

应该将保存文件的功能端放入另一个jsp文件中,用request传递内容

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。