如何在不使用两个JSP文件的情况下在JSP中上传文件?

huangapple 未分类评论42阅读模式
英文:

How can I upload a file in JSP without using two JSP files?

问题

I'm trying to upload file using "Upload File" label.

英文:

I'm trying to upload file using "Upload FIle" label.

答案1

得分: 0

Solo JSP,文件 = upload.jsp

<form method="post" enctype="multipart/form-data">
<input type=file name=file1>
<input type=submit>
</form>

<%
  if (request.getContentType()==null) return;
  <... 上传代码,无论是 Apache Commons 还是纯 JSP...>
%>
<% out.println("文件已上传。");%>
英文:

Solo JSP, file = upload.jsp

<form method="post" enctype="multipart/form-data">
<input type=file name=file1>
<input type=submit>
</form>

<%
  if (request.getContentType()==null) return;
  <... your upload code, whether this is Apache Commons or straight JSP...>
%>
<% out.println("File has been uploaded."); %>

huangapple
  • 本文由 发表于 2020年4月4日 18:24:42
  • 转载请务必保留本文链接:https://java.coder-hub.com/61026708.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定