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

📄 news_modify.jsp

📁 急着下个东西即然还要开通帐号
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*,beitian.db.*,java.io.*" %>
<%@ include file="checkLogin.jsp" %>
<%@ page import="java.util.UUID"%>
<%@ page import="java.io.File"%>
<%@ page import="java.io.FileInputStream"%>
<%@ page import="java.io.IOException"%>
<%@ page import="java.io.FileNotFoundException"%>
<%@ page import="java.io.UnsupportedEncodingException"%>
<%@ page import="java.nio.ByteBuffer"%>
<%@ page import="java.nio.CharBuffer"%>
<%@ page import="java.nio.channels.FileChannel"%>
<%@ page import="java.nio.charset.Charset"%>
<%!
/*' ============================================
' 去除Html格式,用于从数据库中取出值填入输入框时
' 注意:value="?"这边一定要用双引号
' ============================================*/
public String inHTML(String str)
{
	String sTemp;
	sTemp = str;
	if(sTemp.equals(""))
	{
		System.exit(0);
	}
	sTemp = sTemp.replaceAll("&", "&amp;");
	sTemp = sTemp.replaceAll("<", "&lt;");
	sTemp = sTemp.replaceAll(">", "&gt;");
	sTemp = sTemp.replaceAll("\"", "&quot;");
	return sTemp;
}
%>
<%
     String news_id = request.getParameter("news_id") == null ? "0" :request.getParameter("news_id");

     Connection conn = null;
     Statement stmt_1 = null;
     ResultSet result_1 =null;
     
     String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; 
     String dbURL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=chncup_cn"; 
     String userName = "chncup_cn"; 
     String userPwd = "chncup_cn69#$"; 
     
     //java.io.File file = new java.io.File("f:\\wwwchncupcom\\test_0222.txt");          //不要覆盖原来的文件,以便比较
     //java.io.FileOutputStream fos = new java.io.FileOutputStream(file);
     String sql_1="select title,keywords,description,file_length,menu_id,uuid from web_news where news_id="+ news_id;
    
      
      try {  
           Class.forName(driverName); 
           conn = DriverManager.getConnection(dbURL, userName, userPwd); 
           
           stmt_1 = conn.createStatement();
			     result_1 = stmt_1.executeQuery(sql_1);
		  }
      catch(Exception e){
        System.out.println("error: " + e);
       }    
       
     String title = ""; 
     int file_length = 0; 
     int menu_id = 1; 
     String content = "";
     String keywords ="";
     String description ="";
     String sUUID = "";
     
    if (result_1.next()) {      
        title = result_1.getString("title"); 
        file_length = result_1.getInt("file_length"); 
        menu_id = result_1.getInt("menu_id"); 
        keywords = result_1.getString("keywords"); 
        description = result_1.getString("description"); 
        sUUID = result_1.getString("uuid");
     }
        
        
     //java.util.UUID uuid = UUID.randomUUID();
     //String sUUID = uuid.toString();
     
     String sFile ="D:\\www\\eng.chncup.com\\2008.chncup.com\\temp\\"+sUUID+".txt";
     
      Statement stmt = null; // The JDBC Statement object
			ResultSet rs = null;
			String textCopySQL= "exec sp_textcopy 'localhost','chncup_cn','chncup_cn69#$','chncup_cn','web_news','content','"+sFile+"','where uuid=''"+sUUID+"''',o";
			
			
			int iReturn = 0; 
			try{
			   stmt=conn.createStatement();
			   iReturn = stmt.executeUpdate(textCopySQL); 
			}
			catch(Exception e){
			   com.chncup.commen.Log.getLogger().error("insert失败:" + e.getMessage()+" textCopySQL = " + textCopySQL);
      }
      
      StringBuffer rsb = new StringBuffer(); 
		     
      try{

         FileReader fr=new FileReader(sFile);
			   BufferedReader br=new BufferedReader(fr); 
			   
			    String Line=br.readLine();
          
						while(Line!=null)
						{
							 rsb.append(Line);
							 Line=br.readLine();
						}
			      fr.close();
			 } catch(FileNotFoundException e) {}
            
      content = inHTML(rsb.toString());
      rsb.delete(0,rsb.length()); 
      rsb = null;
      
			/*File aFile = new File(sFile);
			FileInputStream inFile = null;
			FileChannel inChannel = null;
			ByteBuffer bb = ByteBuffer.allocateDirect(4096);
			Charset cs = Charset.forName("UTF-8");
			StringBuffer sb = new StringBuffer(1024);
			
			try{
			   inFile = new FileInputStream(aFile);
			} catch(FileNotFoundException e) {}
			
			inChannel = inFile.getChannel();
			
			try {
			
					while(inChannel.read(bb) != -1) {
							bb.flip();
							CharBuffer cb = cs.decode(bb);
							sb.append(cb.toString());
							bb.clear();
					}	
			    inFile.close();
			} catch(IOException e) {}
			*/
			
			//System.out.println(sb.length());
			
			
                   
      /* String sql="select content from web_news where news_id="+news_id;
      
     try {  
		      Statement stmt = conn.createStatement();
		      ResultSet result = stmt.executeQuery(sql);
		      result.next();
		      
		      byte[] b = new byte[file_length];
		      InputStream fis = result.getBinaryStream(1);
		      //while(fis.read(b,0,file_length) != -1){
		      //    fos.write(b,0,file_length);
		      //}
		      //fos.flush();
		      StringBuffer outSB = new StringBuffer();
		      for (int n;(n=fis.read(b))!=-1;) {
		          outSB.append(new String(b,0,n));
		      }
		      content = inHTML(outSB.toString());
     }
     catch(Exception e){
        System.out.println("error: " + e);
     }
     */ 
      
%>
<SCRIPT language="JavaScript" src="../scripts/util.js"></SCRIPT>
<link rel="stylesheet" href="/admin/css/style.css" type="text/css">
<HTML>
<HEAD>
<TITLE>内空发布</TITLE>
<style>
body,td,input,textarea {font-size:9pt}
</style>
<script Language="JavaScript">
<!--
function Check(theForm)
{
	if (theForm.title.value ==""){
		alert("请输入标题名称");
		theForm.title.focus();
		return (false);
	}
	return (true);
}

function changecate()
{
  var obj = document.forms['form1'].elements['parent_id'];

	if (obj.selectedIndex > 0 && obj.options[obj.selectedIndex].className == "leafCat")
	{
      alert("您选择的分类是一个末级分类,请重新选择。");
      obj.selectedIndex = 0;

      return false;
	}
    return true;
}

-->
</script>

</HEAD>
<BODY>
<FORM method="POST" name="myform" action="modify_submit.jsp">
	
<TABLE border="0" cellpadding="2" cellspacing="1" align="center">
<TR>
	<TD><div align="right">标题:</div></TD>
	<TD>
		<input name="news_id" type="hidden" value="<%=news_id%>">
		<input name="sUUID" type="hidden" value="<%=sUUID%>">
		<input name="title" type="text" size="50" maxlength="50" value="<%=title%>"></TD>
</TR>
<TR>
	<TD><div align="right">关键字:</div></TD>
	<TD>
		<input name="keywords" type="text" size="50" maxlength="250" value="<%=keywords%>"></TD>
</TR>
<TR>
	<TD><div align="right">描述:</div></TD>
	<TD><input name="description" type="text" size="50" maxlength="250" value="<%=description%>"></TD>
</TR>
 <tr> 
      <td width="10%"><div align="right">菜单名称:</div></td>
    <td width="90%">
           <select name='menu_id'>
           	<%// onchange="changecate()"
            String sql = "select menu_id,parent_id,menu_name from view_www_menu  where parent_id>0";
    				DBOperation theDBOperation = new DBOperation();
        		ResultSet rs1 = theDBOperation.getResultSet(sql);
            while(rs1.next()){
           %>
           <option value="<%=rs1.getString("menu_id")%>" <%=(rs1.getInt("parent_id")==0)?"":"class=\"leafCat\""%> <%=rs1.getInt("menu_id")==menu_id?"selected":""%>><%=rs1.getString("menu_name")%></option>
           <%}%>
         </select>
         </td>
  </tr>
<TR>
	<TD><div align="right">编辑内容:</div></TD>
	<TD>
		<INPUT type="hidden" name="content1" value="<%=content%>">
		<IFRAME ID="eWebEditor1" src="eWebEditor.jsp?id=content1&style=standard" frameborder="0" scrolling="no" width="650" height="400"></IFRAME>
	</TD>
</TR>
<TR>
	<TD colspan=2 align=right>
	<INPUT type=submit name=b1 value="提交">
	<INPUT type=reset name=b2 value="重填">
	<!--<INPUT type=button name=b3 value="查看源文件" onclick="location.replace('view-source:'+location)">-->
	</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

⌨️ 快捷键说明

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