81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'showlist.jsp' starting page</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="CSS/table.css" type="text/css">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/interface/service.js"></script>
<script type="text/javascript" src="js/comm.js"></script>
<script type="text/javascript">
var num = 1;
function addFile(){
num++;
var obj=document.getElementById("uploadFile");
var innerHTML=obj.innerHTML;
var insertHTML= "文件"+num+":<input type='file' name='testFile["+num+"]' size='30'/> <br> ";
innerHTML=innerHTML+insertHTML;
//alert(innerHTML);
obj.innerHTML=innerHTML;
}
function upload(){
document.forms[0].action+="?method=upload";
document.forms[0].submit();
}
function toAdd(){
document.forms[0].action+="?method=toAdd";
document.forms[0].submit();
}
function dolist(){
document.forms[0].action+="?method=list";
document.forms[0].submit();
}
function toDel(id)
{
document.forms[0].action+="?method=toDelete&id="+id;
document.forms[0].submit();
}
function toUpdate(id)
{
document.forms[0].action+="?method=toUpdate&id="+id;
document.forms[0].submit();
}
</script>
</head>
<body>
<html:form method="post" action="main.do" enctype="multipart/form-data">
<!-- -->
<table width="100%">
<tr>
<td>
<font color="#0000CC">您正在做的业务是:数 据</font>
</td>
</tr>
</table>
<table >
<tr>
<td>公司名称:<input type="text" name="hdCorporation"></td>
<td>件 号:<input type="text" name="hdarticleId"></td>
<td>章节号:<input type="text" name="hdATA"></td>
<td><input type="button" value="添加" onclick="javascript:toAdd();"></input></td>
<td><input type="button" value="查询" onclick="javascript:dolist();"/></td>
</tr>
</table>
<table border="1" width="80%" align="center" >
<TBODY class="TD_STYLE1">
<TR>
<td colspan="2" align="center">
<span id="uploadFile">
文件1:<input type="file" name="testFile[1]" size="30"/><br>
</span>
</td>
</TR>
<TR>
<td align="center">
<input type="button" name="btnAddFile" value="添加文件"
onclick="addFile()"/>
</td>
<TD align="center">
<input type="submit" name="btnUpload" value="上传文件" onclick="upload();"/>
</TD>
</TR>
</TBODY>
</table>
<table width="100%" border="1" cellpadding=0 cellspacing=1
bordercolorlight=#848284 bordercolordark=#eeeee class="TABLE_STYLE1">
<tr align="center">
<td width="8%" class="TD_STYLE1">公司名称</td>
<td width="8%" class="TD_STYLE1">ATA章节号</td>
<td width="12%" class="TD_STYLE1">件号</td>
<td width="8%" class="TD_STYLE1">测试(工时)</td>
<td width="8%" class="TD_STYLE1">修理(工时)</td>
<td width="8%" class="TD_STYLE1">翻修(工时)</td>
<td width="8%" class="TD_STYLE1">修理(固定)</td>
<td width="8%" class="TD_STYLE1">翻修(固定)</td>
<td width="8%" class="TD_STYLE1">保修期</td>
<td width="8%" class="TD_STYLE1">周期</td>
<td width="8%" class="TD_STYLE1">报价日期</td>
<td width="8%" class="TD_STYLE1">操作</td>
</tr>
<logic:iterate name="pb" id="list" property="currentList">
<tr align="center" class="TD_STYLE2">
<td>${list.corporation.corporationName}</td>
<td>${list.articleId.articleIdAta}</td>
<td>${list.articleId.articleIdName}</td>
<td>${list.mainManhourTest}</td>
<td>${list.mainManhourRepair}</td>
<td>${list.mainManhourOverhaul}</td>
<td>${list.mainImmobilityRepair}</td>
<td>${list.mainImmobilityOverhaul}</td>
<td>${list.mainWarrantyTime}</td>
<td>${list.mainCycle}</td>
<td>${list.hddate.dateData}</td>
<td>
<a href="javascript:toUpdate('${list.mainId}');">更新</a>
<a href="javascript:toDel('${list.mainId}');">删除</a>
</td>
</tr>
</logic:iterate>
</table>
<table align="center" class="TD_STYLE9">
<tr>
<td>
总记录数${pb.allRecord}条记录,总页数有${pb.allPage}页,当前是${pb.currentPage}页
从第${pb.first+1}条记录到第${pb.last+1}条记录
</td>
</tr>
<tr>
<td>
<logic:equal value="1" name="pb" property="currentPage">
首页 上一页
</logic:equal>
<logic:greaterThan value="1" name="pb" property="currentPage">
<a href="main.do?method=list&page=1">首页</a>
<a href="main.do?method=list&page=${pb.currentPage-1}">上一页</a>
</logic:greaterThan>
<logic:equal value="${pb.allPage}" name="pb" property="currentPage">
下一页 尾页
</logic:equal>
<logic:lessThan value="${pb.allPage}" name="pb" property="currentPage">
<a href="main.do?method=list&page=${pb.currentPage+1}">下一页</a>
<a href="main.do?method=list&page=${pb.allPage}">尾页</a>
</logic:lessThan>
<input type="text" name="page" size="2">
<input type="button" value="转到">
<a href="index.jsp">返回</a>
</td>
</tr>
</table>
</html:form>
</body>
</html>
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
String encoding = request.getCharacterEncoding();
if((encoding!=null)&&(encoding.equalsIgnoreCase("utf-8"))){
response.setContentType("text/html; charset=gb2312");//如果没有指定编码,编码格式为gb2312
}
UploadForm uf = (UploadForm) form;
ExeclFiliter execlFiliter = new ExeclFiliter();
FormFile file = uf.getTheFile();//取得上传的文件
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.out.println("获取到的文件:"+file);
try {
String filePath = this.getServlet().getServletContext().getRealPath("/");
file.getInputStream();//把文件读入
System.out.println(filePath + "/"+ file.getFileName());
System.out.println(filePath +"UploadFiles\\"+file.getFileName());
new FileOutputStream(filePath +"UploadFiles\\"+file.getFileName());
System.out.println("『『『『『『『『『『『『『");
execlFiliter.intoExecl(filePath +"UploadFiles\\"+file.getFileName());
} catch (Exception e) {
// TODO: handle exception
}
return mapping.findForward("Add_success");
}