jsp按钮问题

wwf06802136 2009-11-10 03:44:26
我想实现通过一个确定按钮提交文本框的内容和上传的文件,请问如何实现,给个具体代码参考,谢谢!
...全文
109 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhufenghappy 2009-11-10
  • 打赏
  • 举报
回复
楼上二位的可行
dying2003 2009-11-10
  • 打赏
  • 举报
回复

public void doUpLoadVideo(UpLoadVideoForm myform) {
String fileName = myform.getVideoURL().getFileName();
FormFile formFile = myform.getVideoURL();
String fileURL = "F:/video/"
String videoPath = fileURL.concat(fileName);
try {
byte[] data = formFile.getFileData();
FileOutputStream os = new FileOutputStream(videoPath);
os.write(data);
os.close();

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

}

UpLoadVideoForm里封装textName、fileName
liguominz 2009-11-10
  • 打赏
  • 举报
回复

<form action="提交路径" method="post">
<input type="text" name="textName"/>
<input type="file" name="fileName"/>
<input type="submin" value="提交">
</from>

然后在提交的路径那里接受
String textName = request.getParameter("textName");
String fileName = request.getParameter("fileName");
File file = new File(fileName); // 创建文件对象

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧