1,從前一個頁面獲取參數後:
String name=request.getParameter("name");
if(name==null)
{ name=""; }
name 是上個界面傳遞的參數,如果沒有數值,則賦值爲空
2,解決中文問題
byte b[]=name.getBytes("ISO-8859-1");
name=new String(b);
建立b數組,重新用編碼編寫一下
3,數據庫代碼
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try{Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e){}
try
{
con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","scott","WJZwjz1029");
sql=con.createStatement();
rs=sql.executeQuery("select * from emp");
……
}
catch(SQLException e1) {out.print(""+e1);}
finally
{
con.close
}