⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.jsp~198~

📁 《struts应用开发完全手册》中的源代码及安装指导
💻 JSP~198~
字号:
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*,com.actionForm.FileActionForm" errorPage=""%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <title>利用Struts框架实现文件的上传和下载</title>
  </head>
<script language="javascript" type="">
function Mycheck(){
if (fileActionForm.fileName.value=="")
{ alert("请输入上传文件的名称!");fileActionForm.fileName.focus();return  false;}
if (fileActionForm.file.value=="")
{ alert("请选择上传文件的路径!");fileActionForm.file.focus();return false;}
form.submit();
}
</script>
<%
com.dao.FileDao dao=new com.dao.FileDao();

java.util.List list=dao.selectFile();
int number=list.size();//计算有多少条纪录
int row=number/3;
if(number/3!=0){
row=row+1;
}
%>
  <body>
    <br>
    <p align="center">利用Struts框架实现文件的上传和下载</p>

    <table width="233" border="1" align="center">
   <%for(int i=0;i<list.size();i++){
   FileActionForm  form=(FileActionForm)list.get(i);
if(i%2==0){
 %>
      <tr>
         <td width="81" height="51">

           <table width="264" height="81" border="1" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115"  rowspan="4" align="center"><img src="<%=form.getFilePath()%>" width="100" height="100"></td>
        <td width="133" align="center">图片名称:<%=form.getFileName()%></td>
      </tr>
      <tr align="center">
        <td>图片大小:<%=form.getFileSize()%></td>
      </tr>
      <tr align="center">
        <td>上传日期:<%=form.getFileDate()%></td>
      </tr>
	   <tr>
        <td align="center"><a href="fileAction.do?method=downFile&path=">下载图片</a></td>
      </tr>
    </table>

         </td>
<%}else{%>
         <td width="81">






         </td>
      </tr>
<%}}%>
<%if(list.size()%2==1){%>
            <td>&nbsp;</td>
                    </tr>
<%}%>
  </table>
    <html:form action="fileAction.do?method=upLoadFile" enctype="multipart/form-data" onsubmit="return Mycheck()">
<table height="52" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr align="center">
          <td width="60" height="26">图片名称:</td>
          <td width="160">
            <html:text property="fileName"/>
          </td>
          <td width="60">图片路径:</td>
          <td width="198">
            <html:file property="file"/>
          </td>
        </tr>
        <tr align="right">
          <td height="26" colspan="4">
            <html:submit>上传</html:submit>
          </td>
        </tr>
    </table>
  </html:form>

  </body>
</html:html>

⌨️ 快捷键说明

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