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

📄 shownewssingletitle.java

📁 JAVA邮件系统
💻 JAVA
字号:
/* 
 *
 */

import java.io.*;
import java.text.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ShowNewsSingleTitle extends HttpServlet {

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		HtmlOut htmlOut = new HtmlOut(response);
		String sCateid=new String ();
		sCateid=request.getParameter ("cateid");
		if ((sCateid==null)||(sCateid.trim ().length ()!=8))
		{
		   	htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请输入新闻类别","http://www.365do.com");
			htmlOut.outHtml ();
			return;
		}
       ////////////////////////////////////////////
	   TemplateList tempList;
	   news News=new news();
      
	//根据输入的新闻频道名称得不同的模板
	   tempList= CommonMethods.getShowSingleTitleTemplate ();
	   SingleTemplate st,st1;
	   st = tempList.searchTemplate ("ROOT");
	   st1= tempList.searchTemplate ("标题列表");
	   String sNewsShortTitle=new String ();
	   String sNewsId=new String ();
	   String sKey=new String ();
	   if(st==null)
		{
			  return;
		}
	   if (st1==null)
	   {
			return;
	   }
	   
	    DBOperater DB=new DBOperater ("news");
		ResultSet rs=DB.executeQuery ("select newsid ,abstract,make,shorttitle from news where cateid='"+sCateid+"' ORDER by make DESC");
		int nKey=st.getKeyNum ();
		String sAbstract=new String();
		String sKey1=new String ();
		Calendar   dMakeTime=Calendar.getInstance () ;
	//	int k=1;
	//	int count=20;
		int nKey1=st1.getKeyNum ();
		int nDay=0;
		for(int i=0;i<nKey;i++){
			htmlOut.addString (st.getStringAt (i));
			sKey = st.getKeyAt (i);
			if( sKey.compareTo("cgi-path")==0 )
				htmlOut.addString (CommonMethods.sHostNameCGI);
			if (sKey.compareTo ("栏目名称")==0)
			    htmlOut.addString (News.getCateName (sCateid));
			if ((sKey.compareTo ("内容")==0))
			{   
				if (rs!=null){
				try{
					while(rs.next ()){
					//	if( k>count)
				//			break;
						try{
							sNewsId=rs.getString (1);
							sAbstract=rs.getString (2);
							dMakeTime.setTime (rs.getTimestamp  (3));
							sNewsShortTitle=rs.getString (4);
							if((sNewsShortTitle!=null)&&(sNewsShortTitle.trim ().length ()>1)&&(sAbstract!=null)&&(sAbstract.trim ().length ()>1))
							{  
								for (int j=0;j<nKey1;j++){
									htmlOut.addString (st1.getStringAt (j));
									sKey1 = st1.getKeyAt (j);
									if( sKey1.compareTo("cgi-path")==0 )
										htmlOut.addString (CommonMethods.sHostNameCGI);
									if (sKey1.compareTo ("新闻标题")==0)
										htmlOut.addString(sNewsShortTitle);
									if (sKey1.compareTo ("单条新闻")==0)
									{
										htmlOut.addString("SingleNews?id=");
										htmlOut.addString(sNewsId);
										htmlOut.addString("&cateid=");
										htmlOut.addString(sCateid);
									}
									if (sKey1.compareTo ("时间")==0)
									{
											
									 	int nHour=0;
									 	int nMinute=0;
									 	nDay=dMakeTime.get (dMakeTime.DATE);
											
									 	nHour=dMakeTime.get(dMakeTime.HOUR_OF_DAY );
											
									 	nMinute=dMakeTime.get (dMakeTime.MINUTE  );
									 //	System.out.println ("dsafasdfsadf"+nMinute);
									 	htmlOut.addString(nDay+"日");
											
									 	if (nHour>=10)
									 		htmlOut.addString (nHour+":");
									 	else
											
									 		htmlOut.addString ("0"+nHour+":");
									 	if (nMinute>=10)
									 		htmlOut.addString(nMinute+"");
									 	else
									 		htmlOut.addString ("0"+nMinute);
									}
		             			}
					               //k++
									htmlOut.addString (st1.getEndString ());
								}
								}
							catch(Exception e ){
								continue;
							}
			
						}
					}catch(Exception e){
						DB.close ();
						return ;
					}
				}	
				}				
			}	
			DB.close ();
			htmlOut.addString (st.getEndString());
			//out.println (st.getEndString());
			htmlOut.outHtml();
			return;
	   ///////////////////////////////////////////
		}
	
       public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		doGet(request,response);
	}
}

⌨️ 快捷键说明

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