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

📄 shownewstitle.java

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

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

public class ShowNewsTitle extends HttpServlet {

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		HtmlOut htmlOut = new HtmlOut(response);
		String sCategory=new String ();
		sCategory=request.getParameter ("cate");
		if ((sCategory==null)||(sCategory.trim ()==""))
		{
		   	htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请输入新闻类别","http://www.365do.com");
			htmlOut.outHtml ();
			return;
		}
		sCategory=CommonMethods.DealWithGBCodeOfRequest (sCategory);
		//根据得到的新闻类别名称找到相应的模板文件
		TemplateList tempList=new TemplateList ();
		if (sCategory.trim ().compareTo ("要闻类")==0)
			tempList=CommonMethods.getImportNewsTemplate ();
		
		if (sCategory.trim ().compareTo ("新闻类")==0)
			tempList=CommonMethods.getNewsTemplate ();

		if (sCategory.trim ().compareTo ("金融类")==0)
			tempList=CommonMethods.getFinanceNewsTemplate  ();

		if (sCategory.trim ().compareTo ("经济类")==0)
			tempList=CommonMethods.getEconomyNewsTemplate  ();

		if (sCategory.trim ().compareTo ("体育健身类")==0)
			tempList=CommonMethods.getSportNewsTemplate  ();

		if (sCategory.trim ().compareTo ("旅游休闲")==0)
			tempList=CommonMethods.getLeisureNewsTemplate  ();

		if (sCategory.trim ().compareTo ("影视娱乐")==0)
			tempList=CommonMethods.getFilmNewsTemplate  ();

		if (sCategory.trim ().compareTo ("文学艺术")==0)
			tempList=CommonMethods.getLetterNewsTemplate  ();

		if (sCategory.trim ().compareTo ("媒体文摘")==0)
			tempList=CommonMethods.getTabloidNewsTemplate  ();

		if (sCategory.trim ().compareTo ("网络资讯")==0)
			tempList=CommonMethods.getNetNewsTemplate ();

		if (sCategory.trim ().compareTo ("房地产类")==0)
			tempList=CommonMethods.getHouseNewsTemplate  ();

		if (sCategory.trim ().compareTo ("人才招聘")==0)
			tempList=CommonMethods.getJobNewsTemplate  ();

		if (sCategory.trim ().compareTo ("科技教育")==0)
			tempList=CommonMethods.getEducateNewsTemplate ();

		if (sCategory.trim ().compareTo ("电脑网络")==0)
			tempList=CommonMethods.getComputerNewsTemplate  ();

		if (sCategory.trim ().compareTo ("地方资讯")==0)
			tempList=CommonMethods.getLocalNewsTemplate  ();

		if (sCategory.trim ().compareTo ("生活服务")==0)
			tempList=CommonMethods.getLiveNewsTemplate  ();

		if (sCategory.trim ().compareTo ("消费市场")==0)
			tempList=CommonMethods.getConsumeNewsTemplate  ();
		
		
		//模板替换
		/*String sCateid;
        DBOperater DB = new DBOperater ("category");
		ResultSet rs = DB.executeQuery ("select cateid from category where name='"+sCategory+"' and folder='T'");
			if(rs!=null){
			try{
			if( rs.next () )
			    sCateid=rs.getString ("cateid");
			}
			catch(Exception e){
				}
			 }
			else{
				htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请输入正确新闻类别","http://www.365do.com");
			    htmlOut.outHtml ();
				DB.close();
				return;	
			}
		DB.close ();*/
/*		sLmdm=sLmdm+"%";
		String[] sCateId=new String ();
		DBOperater DB1=new DBOperater ("category");
		ResultSet rs1=DB1.executeQuery ("select cateid ,count(*) from category where lmdmLIKE '"+sLmdm+"'");
		if(rs!=null){
			try{
			while( rs.next () )
			    sLmdm=rs.getString ("cateid");
			}
			catch(Exception e){
				}
			 }
		else{
				htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"该类别没有栏目","http://www.365do.com");
			    htmlOut.outHtml ();
				return;	
			}*/
		
	/*	if ((sNewsFrom==null)||(sNewsFrom.trim ()==""))
			sNewsFrom="";
		else
			sNewsFrom="摘自《"+sNewsFrom.trim ()+"》";
			sNewsMakeTime=sNewsMakeTime.substring(0,16);
			////////////////////////////
			sNewsAbstract=CommonMethods.DealWithSQLParameter (sNewsAbstract);
			sNewsShortTitle=CommonMethods.DealWithSQLParameter  (sNewsShortTitle);
			sNewsFrom=CommonMethods.DealWithSQLParameter  (sNewsFrom);
			//得到输出单条新闻的模板
			TemplateList tempList=CommonMethods.getSingleNewsTemplate   ();*/
			SingleTemplate st;
			st = tempList.searchTemplate ("ROOT");
			if(st==null)
			{
			return ;
		
			}
			int nKey = st.getKeyNum ();
			String sKey= new String ();
			String sCateid=new String ();
			String sAbstract=new String ();
			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);
				DBOperater DB = new DBOperater ("category");
				ResultSet rs = DB.executeQuery ("select cateid from category where name='"+sKey+"'");
				if(rs!=null){
				try{
				if( rs.next () )
					sCateid=rs.getString (1);
				 }
				catch(Exception e){
				}
				}
				DB.close ();
				if ((sCateid!=null)&&(sCateid.trim().length ()>=1))
				{
					DBOperater DB1=new DBOperater ("news");
					ResultSet rs1=DB1.executeQuery ("select newsid,abstract,shorttitle from news where cateid='"+sCateid+"' ORDER BY  make DESC");
					if(rs1!=null){
						try{
							SingleTemplate st1;
							st1=tempList.searchTemplate ("新闻栏目");
							if (st1==null){
								return ;
							}
							int nKey1=st1.getKeyNum ();
							String sKey1=new String ();
							int nNewsId;
							String sNewsShortTitle= new String ();
							String sTitle="";
							int maxNum=5;
							int k=1;
							while(rs1.next ())
							{   
							//	if (k>maxNum)
							//		break;
								nNewsId=rs1.getInt (1);
								try{
									sAbstract=rs1.getString (2);
									sNewsShortTitle=rs1.getString (3);
								}catch(Exception e){
									continue;
								}
								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);
										sTitle="";
										sTitle+="<a href=SingleNews?id=";
										sTitle+=nNewsId;
										sTitle+="&cateid=";
										sTitle+=sCateid;
										sTitle+=">";
										sTitle+=sNewsShortTitle;
										sTitle+="</a>";
										if( sKey1.compareTo("cgi-path")==0 )
											htmlOut.addString (CommonMethods.sHostNameCGI);
										if (sKey1.compareTo ("新闻标题")==0)
											htmlOut.addString (sTitle);
										htmlOut.addString (st1.getEndString ());
									}//end for
									k++;
								}//end if
								
							}//end while
						}//end try
						catch(Exception e){
						}
					}	
					DB1.close ();
				}
			}
			htmlOut.addString(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 + -