england_news_info.jsp

来自「手机在线系统 采用Java 中的J2ME, JSP 跟MySql 运行环」· JSP 代码 · 共 80 行

JSP
80
字号
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*, com.j2me.common.*, com.j2me.data.*"%>
<HTML>

<HEAD>

<TITLE> New Document </TITLE>

</HEAD>

<BODY>
<%
    /**
	  * @(#)england_news_info.jsp	1.11 01/08/23
	  * Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
	  * @version 	1.0, 10/05/2004
	  * @author 	饶荣庆
	  * @author 	余煜辉
	  */

	 /*此文件用于获得新闻主要内容*/

	 FootBall foot = null;	//数据库类
	 String name =request.getParameter("name");	  //获得参数

	 //获得球队名的参数,并查询它
	 String sql ="select *from england_news where title = '" + name + "'"; 
	 
	 try
	 {
		 foot = new FootBall();
		 foot.connect();	   //连接数据库
	 }
	 catch(ClassNotFoundException e)
	 {
         out.println(e.getMessage());
	 }

	 try
	 {
		 String title = null; 
		 String body = null;
		 String news_info = null;

		 ResultSet rs = foot.view(sql);	 //显示数据

		 /*---------------------------------------------------------------------------------
		  *获取数据库信息
		  */
		  while(rs.next())
		  {
			 title = rs.getString(1);
             body = rs.getString(2);
			 news_info = title + " ---- " + body;
		  }

		/*-------------------------------------------------------------------------------------*/
       	 //转换中文
		 byte[] tmpbyte = news_info.getBytes("8859_1"); 
         news_info = new String(tmpbyte); 

	     //把中文字符转换为Unicode吗
		 news_info = Unicode.stringToUnicode(news_info);
		 out.println(news_info);
		
	 }

	 catch(SQLException sqlexception)
     {
		 out.println(sqlexception.getMessage());	 //输出连接错误
	 }

	 foot.disconnect(); //注销数据库
%>


</BODY>
</HTML>


⌨️ 快捷键说明

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