jsp ´«stringÀàÐͲÎÊý
ÎÒµÄÒ»¸öjsp²¿·Ö´úÂ룬ÆäÖÐidÊÇÉÏÒ»¸öÒ³Ãæ´«¹ýÀ´µÄ²ÎÊý£¨Êý¾Ý¿â²éѯµÃµ½µÄ¶¯Ì¬Êý¾Ý£©£º
String id;
try
{
id= request.getParameter("id");
}catch(Exception e){
id="wrong";
}
%>
<%
String DBURL="jdbc:postgresql://localhost/postgres";
String user="postgres";
String password="postgres";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String sqlString1=null;
try{
Class.forName("org.postgresql.Driver").newInstance();
con=DriverManager.getConnection(DBURL,user,password);
}catch(ClassNotFoundException e){
out.println("ClassNotFoundException:"+e.getMessage());
}
if(id!="wrong"){
sqlString1="select office_id,company_name,line_1_label_address,line_2_label_address,line_3_label_address,line_4_label_address,line_5_label_address,postal_code,telephone,facsimile,email from xinaddress where company_name="+id;
ÎÒÔËÐÐʱ£¬ÎÒ´ÓÉÏÒ»¸öÒ³Ãæ½øÕâ¸öÒ³ÃæÊ±×ÜÊdzöÏÖ´íÎó£¬
˵
SQL Exception!:ERROR: syntax error at or near "Shipping"
µ«ÊÇÎÒÈç¹û´«µÄ²ÎÊýÊÇintÀàÐÍʱ
ÉÏÃæÓÃ
int id;
try
{
id= Integer.parseInt(request.getParameter("id"));
}catch(Exception e){
id=0;
Ïà¹ØÎÊ´ð£º
ÎҵĿª·¢µÄƽ̨ÊÇMyeclipes6.0 + tomcat5.x + mysql
ÎÒËùÓеıàÂ뷽ʽ¶¼ÊÇÓõÄUTF-8
ÎÒÖ»ÓÃÁËStrtus¿ò¼Ü
ÔÚÒ»¸öformÖÐÈçÏÂÓõÄÊÇpostµÄÌá½»·½Ê½£º
<form class="form" action=&quo ......
//Óÿͻ§µÄsessionµÄid½¨Á¢Ò»¸öÁÙʱÎļþ£º
//String tempFileName=(String)session.getId();
String tempFileName = (String)session.getId();
//out.println(& ......
<html><head><title>[@title]</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<script language='javascript'>
function diyCheck ......
Ò»¸öÃû³Æ,ÐèÒªÊäÈëµÄ£¬Ò»¸öÏÂÀ²Ëµ¥£¬Ñ¡ÔñµÄ£¬¸ù¾ÝÕâÁ½¸ö½øÐÐÄ£ºý²éѯ¡£ÔÚ·þÎñÆ÷¶ËÎÞÂÛÊäÈëÓë·ñ£¬¶¼Äܵóö²éѯ½á¹û¡£
µ«ÊÇ·ÃÎʵϰ£¬Ö»ÓÐÔÚÊäÈëÃû³ÆµÄʱºò£¬ÔÙÑ¡ÔñÏÂÀ²Ëµ¥²ÅÄܲéѯ£¬Èô²»ÊäÈëÃû³Æ£¬Ö»Ñ¡ÔñÏÂÀ²Ëµ ......
ÐÂÊÖ:
tomcat+struts 2.0
jsp Ò³ÃæÖ±½Ó¹ØÁªmodel
ÏÖÔÚÐèÒª¸ù¾Ýmodel(admin)ÀïÃæµÄÒ»¸öitem(id),ÅжÏjspÒ³Ãæ³öÏÖµÄÄÚÈÝ.
´ó¸ÅÁ÷³Ì:
...
<table>
<tr>
<td>
<s:if admin.id is null> ......