Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSPÊý¾Ý¿âÁ¬½Ó´óÈ«

JSPÊý¾Ý¿âÁ¬½Ó´óÈ«
2008-07-22 11:47
Ò»¡¢jspÁ¬½ÓOracle8/8i/9iÊý¾Ý¿â£¨ÓÃthinģʽ£©
testoracle.jspÈçÏ£º
< %@ page contentType="text/html;charset=gb2312"% >
< %@ page import="java.sql.*"% >
< html >
< body >
< %Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orclΪÄãµÄÊý¾Ý¿âµÄSID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {% >
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(1)% >
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(2)% >
< %}% >
< %out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");% >
< %rs.close();
stmt.close();
conn.close();
% >
< /body >
< /html >
¶þ¡¢jspÁ¬½ÓSql Server7.0/2000Êý¾Ý¿â
testsqlserver.jspÈçÏ£º
< %@ page contentType="text/html;charset=gb2312"% >
< %@ page import="java.sql.*"% >
< html >
< body >
< %Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubsΪÄãµÄÊý¾Ý¿âµÄ
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {% >
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(1)% >
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º< %=rs.getString(2)% >
< %}% >
< %out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");% >
< %rs.close();
stmt.close();
conn.close();
% >
< /body >
< /html >
Èý¡¢jspÁ¬½ÓDB2Êý¾Ý¿â
testdb2.jspÈçÏ£º
< %@ page c


Ïà¹ØÎĵµ£º

jsp ÍøÂç

 ÔÚtomcatÏÂÕÒµ½tomcat -> conf -> server.xml ÔÚÕâÒ»¾äÖÐÌí¼ÓºìÉ«²¿·Ö
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"
/> <!--URLEncoding=""--> ± ......

Google·ÖÒ³¹¦ÄܵÄjsp±êǩʵÏÖ

 ÏÂÃæÊÇjsp´úÂë<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="com.yourcompany.struts.action.Student" %>
<%@ t ......

JSPÂÒÂëÖÕ¼«½â¾ö£¨ÊµÓã©

 JspÊÇÒ»¸öºÜÈÈÃŵĻ°Ì⣬µ«Èôó¶àÊýÈ˶¼Í·Í´µÄÊÇJSPÒ³ÃæÖеÄÂÒÂëÎÊÌ⣬±ÊÕßÉíÓÐÌå»á£»ÔøΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌâÓôÃÆÁ˺ü¸Ì죬ÊÔÁ˺ܶ෽·¨¶¼²»ÐС£×îºóÔÚJSPרҵÈËÊ¿µÄ°ïÖúÏ£¬ÖÕÓÚ½â¾ö¡£Ö®ºó±ÊÕßÔø¶Ô´Ë×öÁËһЩСµÄÑо¿¡£  
  Ê×ÏÈÎÒÃÇÏÈÁ˽âÒ»ÏÂÎÊÌâµÄÔ­Òò¡£Ò»°ãÇé¿öÔÚÔÚÿ¸öJSPÒ³µÄÍ·²¿¶¼ÓÐÕâÑùÒ» ......

½«jspÍøÒ³Êý¾ÝÊä³öΪExcel»òWordÎļþ

½«Ò»¸öJSPÒ³ÃæÖеÄ<%@ page contentType="text/html; charset=GBK" language="java" %>Ì滻Ϊ
<%@ page contentType="application/vnd.ms-Excel;charset=GBK" language="java"%> //Excel
»ò
<%@ page contentType="application/vnd.ms-word;charset=GBK" language="java"%> //Word
ÔÚÒ³Ã濪ʼÊä³öÊý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ