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

📄 new.jsp

📁 运用jdk
💻 JSP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=gb2312"%>
<%@page import="java.util.*,java.text.*"%>
<%
	
	//新闻表
	com.util.DealString ds = new com.util.DealString();
	String step = ds.toString(request.getParameter("step"));
	String addtime = ds.toString(request.getParameter("addtime"));
	String froms = (String)session.getAttribute("ID");
	String title = ds.toString(request.getParameter("title"));
	String content = ds.toString(request.getParameter("content"));


	//附件表
	String strfile = ds.toString(request.getParameter("strfile"));
	String strname = ds.toString(request.getParameter("strname"));
	String strsize = ds.toString(request.getParameter("strsize"));
	String upmonth = ds.toString(request.getParameter("upmonth"));
	String mod = ds.toString(request.getParameter("mod"));
	String cursize = "0" ;
	
	//新闻编号
	String sql = "" ;
	com.db.CommonBean myBean = new com.db.CommonBean();
	myBean.init("kjc_publish","addtime desc","id#NUM#1#title#CHAR#0#content#CHAR#0#back#CHAR#0#addtime#CHAR#0#endtime#CHAR#0#froms#NUM#0#tos#NUM#0#fielid#CHAR#0#model#NUM#0#url#CHAR#0#ifpost#CHAR#0#ifread#CHAR#0#toall");
		
	String id = ds.toString(request.getParameter("id")) ;
	if(!step.equals(""))
	{
		Hashtable hash = new Hashtable ( ) ;
		hash.put ( "title" , title );
		hash.put ( "content" , content );
		hash.put ( "addtime" , addtime );
		hash.put ( "froms" , froms );
		hash.put ( "model" , "6" );
		
		//新文章编号
		if(step.equals("new"))id = "" + myBean.add ( hash ) ;
		else {myBean.setID(id);myBean.mod(hash);}

		//如果是修改则先清空
		if(step.equals("mod"))
		{
			myBean.getDataBySql("delete from kjc_file where objectid="+id);
		}
		

		//填写附件表
		String t_strfile[] = ds.splitStr ( strfile , ',' ) ;
		String t_strname[] = ds.splitStr ( strname , ',' ) ;
		String t_strsize[] = ds.splitStr ( strsize , ',' ) ;
		for(int i = 0 ; i < t_strfile.length; i++ )
		{	
			if(t_strfile[i].equals(""))continue;
			sql="insert into kjc_file(objectid,oldname,newname,size,updatetime,upman,isattach) "
				+"values("+id+",'"+t_strfile[i]+"','"+t_strname[i]+"','"+t_strsize[i]+"','"+ds.getDateTime().substring(0,10)+"',"+froms+",1)";
			myBean.getDataBySql(sql);
		}
		out.println("<script>alert('成功提交!');</script>");
		response.sendRedirect("../main/main.jsp");
	}

	//查询
	if(!id.equals(""))
	{

		//选择文章信息
		myBean.setID( id ) ;
		Hashtable hash = myBean.getOneData ( ) ;
		addtime = ds.toString((String)hash.get("addtime"));
		froms = ds.toString((String)hash.get("froms"));
		title = ds.toString((String)hash.get("title"));
		content = ds.toString((String)hash.get("content"));


		//选择附件信息
		sql = "select * from kjc_file where objectid="+id+" order by updatetime desc" ;

		Vector vect1 = myBean.getDataBySql(sql);
		strfile = "" ;
		strname = "" ;
		strsize = "" ;
		long size = 0 ;

		for(int i =0 ; i < vect1.size ( ) ; i++ )
		{
			Hashtable h = (Hashtable) vect1.get( i ) ;
			String t = (String)h.get("size") ;
			String newname = (String)h.get("newname") ;
			if(!strfile.equals(""))strfile += "," ;
			if(!strname.equals(""))strname += "," ;
			if(!strsize.equals(""))strsize += "," ;
			strfile += (String)h.get("oldname");
			strname += newname;
			strsize += t;
			if(t.equals(""))t="0";
			size += Long.parseLong(t);

			//以后再上传到本路径			
			upmonth = newname.substring(0,11);
		}
		cursize = "" + size ;

		step = "mod";
	}
	else
	{
		step = "new" ;
	}
	if(addtime.equals(""))addtime = ds.getDateTime().substring(0,10);
		
	myBean.closeConn ( ) ;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../index.css" type="text/css">
<title>发表相关文件</title>
<style>
.inputnull {
	border-top:0px ;border-bottom:0px;border-left:0 px;border-right:0px;
}
</style>
</head>

<body>
<table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40">&nbsp;</td>
    <td width="910"><table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="20" class="title_s">&nbsp;您已登陆: <%=(String)session.getAttribute("NAME")%> </td>
        </tr>
        <tr>
          <td height="5" bgcolor="#A3BED9"></td>
        </tr>
        <tr>
          <td height="1" bgcolor="#0A1870"></td>
        </tr>
    </table></td>
    <td width="50">&nbsp;</td>
  </tr>
</table>

<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40">&nbsp;</td>
	<td>
<TABLE  width="100%" border=1 cellPadding=5 cellSpacing=0 bordercolor="ffffff" class="main1">
  <TBODY>
  <SCRIPT language=javascript>
<!--

	function rightStr(str,n)
	{
		if(str.length<=n)
		{
			return(str);
		}
		{
			return(str.substr(str.length-n,n));
		}
	}
	function addcontent(str1,str2)
	{
		form1.content.focus();
		if ((document.selection)&&(document.selection.type== "Text"))
		{
			var range= document.selection.createRange();
			var ch_text=range.text;
			range.text= str1 + ch_text + str2;
		} 
		else
		{
			document.form1.content.value=document.form1.content.value+str1+str2;
			form1.content.focus();
		}
	}
	function submitonce(theform)
	{
		if (document.all||document.getElementById)
		{
			for (i=0;i<theform.length;i++)
			{
				var tempobj=theform.elements[i];
				if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
		document.all.content.value = frames.message.document.body.innerHTML;
	}

	function storeCaret (textEl)
	{
		if (textEl.createTextRange) 
		textEl.caretPos = document.selection.createRange().duplicate(); 
	}
	
	function checklength(){alert("帖子内容长度: "+document.form1.content.value.length+" 个字,\n最多允许16384字节。");}
	function ctlkey()
	{
		if(event.ctrlKey && window.event.keyCode==13){submitonce(document.form1);document.form1.submit();}
		if(event.altKey && (window.event.keyCode==83 || window.event.keyCode==115)){submitonce(document.form1);document.form1.submit();}
	}
	var ie = (document.all)? true:false
	if (ie)
	{
		window.document.onkeydown=ctlkey;
	}
		

function go()  
		{
	
			
				
	var go = "";
	var strfile=document.all.strfile.value;
	var strname=document.all.strname.value;
	var strsize=document.all.strsize.value;
	var cursize=document.all.cursize.value;
	var onesize=document.all.onesize.value;
	var sumsize=document.all.sumsize.value;
	var upmonth=document.all.upmonth.value;
	var savedir=document.all.savedir.value;
	var count=document.all.count.value;
	
	go = "../UploadCom/upload.jsp?strfile="+ strfile +"&strname=" + strname + "&strsize="+strsize+"&onesize="+onesize+"&cursize="+cursize+"&sumsize=" + sumsize + "&upmonth=" + upmonth+"&savedir=" + savedir+"&count=" + count;
	var oawin = window.open(go,"_blank","toolbar=0,left=231,top=196,status=1,menubar=0,scrollbars=yes,resizable=1,width=600,height=550");
	oawin.focus();
	oawin.opener=window;
		
}
//-->
</SCRIPT>
    <TR bgcolor="ffffff">
      <TD colSpan="2" class="title_s">发表相关文件</TD>
    </TR>
  <FORM name=form1 onsubmit="submitonce(this);" action="new.jsp" method="post">
  <input type=hidden name=step value="<%=step%>">
  <input type=hidden name=mod value="<%=mod%>">
  <input type=hidden name=id value="<%=id%>">
    <TR bgcolor="E7F2FF">
      <TD width=150>发布日期</TD>
      <TD><INPUT name="addtime" type=text class="inputnull" id="addtime" maxLength="20" readonly value="<%=addtime%>"></a>
      </TD>
    </TR>
    <TR bgcolor="E7F2FF">
      <TD width=150>发布人</TD>
      <TD><INPUT name="froms" type=text class="inputnull" id="froms" maxLength="20" readonly value="<%=(String)session.getAttribute("NAME")%>"></TD>
    </TR>
    <TR bgcolor="E7F2FF">
      <TD width=150> 相关文件主题</TD>
      <TD>
          <INPUT name="title" type=text  class=fminpt id="title" size=55 maxLength=255 value="<%=title%>">
    </TD>
    </TR>
    </TR>

		
                <tr bgcolor="E7F2FF">
                  <td width=150 vAlign=middle bgcolor="E7F2FF" class=TBBG1>内容<br>
                      <br></td>
                  <TD bgcolor="E7F2FF" class=TBBG9>		
	<jsp:include page="eokedit.jsp"/>
	<br>
	<script language="javascript">
		document.write('<iframe bgcolor=red src="text.jsp?id=<%=id%>" id=message width=90% height=400 marginheight=0 marginwidth=0 ></iframe>');	
		frames.message.document.designMode = "On";




	</script><input type="hidden" name="content">

   </TR>
	
	<TR bgColor="E7F2FF">
    </TR>
	    <TR bgcolor="E7F2FF">
      <TD width=150>上传附件</TD>
      <TD>


<%

	//初始化总大小
	int onesize = 20*1024*1024;
	int sumsize = 100*1024*1024;

	//初始化年月日-------------------------------------------------
	if(upmonth.equals(""))
	{
		upmonth = ds.getDateTime ( ) .substring ( 0 , 10 ) ;
		upmonth = ds.Replace ( upmonth , "-" , "/" ) + "/" ;
	}
	//新建目录
	String savedir = request.getRealPath("/")+"web/UploadPath/";
	savedir = savedir.replaceAll("\\\\","/");
	//初始化年目录
	java.io.File f = new java.io.File ( savedir + upmonth.substring ( 0 , 5 ) ) ;
	if ( !f.exists ( ) ) { f.mkdir ( ) ; }
	//初始化月目录
	f = new java.io.File ( savedir + upmonth.substring ( 0 , 8 ) ) ;
	if ( !f.exists ( ) ) { f.mkdir ( ) ; }
	//初始化日目录
	f = new java.io.File ( savedir + upmonth.substring ( 0 , 11 ) ) ;
	if ( !f.exists ( ) ) { f.mkdir ( ) ; }
%>
<input type=text name=strfile class="inputnull" size=55 value="<%=strfile%>" readonly>
<INPUT class="fmbtn" type="button" value="上传" name="send" onclick="go()">
<input type=hidden name=strname value="<%=strname%>">
<input type=hidden name=strsize value="<%=strsize%>">
<input type=hidden name=cursize value="<%=cursize%>">

<input type=hidden name=onesize value="<%=onesize%>">	
<input type=hidden name=sumsize value="<%=sumsize%>">		
<input type=hidden name=savedir value="<%=savedir%>">		
<input type=hidden name=upmonth value="<%=upmonth%>">		
<input type=hidden name=count value="10">						
<input type=hidden name=goto value=""></TD>
	    </TR>
    <TR bgColor="E7F2FF">
      <TD colSpan="2" align="middle"><INPUT class="fmbtn" type=submit value=" 完 成 " name="submit" >
          <INPUT class="fmbtn" type=reset value=" 重 写 " name="reset">      </TD>
    </TR>
  </FORM>
</TABLE>
</td>
<td width="50">&nbsp;</td>
</tr>
</table>
</body>
</html>

⌨️ 快捷键说明

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