fileupload.jsp

来自「使用jsp+Servlet,采用MVC模式,实现了一典型小型电子商务网站的全过程」· JSP 代码 · 共 41 行

JSP
41
字号
<%@ page contentType="text/html;charset=GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String contextPath=request.getContextPath();
  System.out.print(request.getParameter("product_pic") + "=================");
  String product_pic = "cover.jpg";
 if(request.getParameter("product_pic") != null && !"".equals(request.getParameter("product_pic")))
    product_pic = request.getParameter("product_pic");
  
 
    
%>
<script>
  parent.frm.attr4.value = "<%=product_pic%>";
  function frmSubmit()
  {
    if(frm.picPath.value == null || frm.picPath.value == "")
    {
      alert('请选择上传文件');
      return;
    }
    frm.submit();
  }
</script>
<form name="frm" action="../../product/fileUpload" method="post" enctype="multipart/form-data">
  <table>
    <tr>
      <td>
        <img src="<%=contextPath%>/productPic/<%=product_pic%>" width="95" height="119">
      </td>
      <td>
        <input type="file" name="picPath">
      </td>    
      <td>
        <input type="button" value="上传" onclick="frmSubmit()">
      </td>
    </tr>
  </table>
</form>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?