﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-火星的森林-随笔分类-Java</title><link>http://www.blogjava.net/marsforest/category/13007.html</link><description>欢迎到火星来</description><language>zh-cn</language><lastBuildDate>Thu, 12 Apr 2007 04:33:29 GMT</lastBuildDate><pubDate>Thu, 12 Apr 2007 04:33:29 GMT</pubDate><ttl>60</ttl><item><title>JSP下拉框联动如何实现(zt)</title><link>http://www.blogjava.net/marsforest/archive/2007/04/12/110092.html</link><dc:creator>火星的森林</dc:creator><author>火星的森林</author><pubDate>Thu, 12 Apr 2007 02:21:00 GMT</pubDate><guid>http://www.blogjava.net/marsforest/archive/2007/04/12/110092.html</guid><wfw:comment>http://www.blogjava.net/marsforest/comments/110092.html</wfw:comment><comments>http://www.blogjava.net/marsforest/archive/2007/04/12/110092.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/marsforest/comments/commentRss/110092.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/marsforest/services/trackbacks/110092.html</trackback:ping><description><![CDATA[两种方案 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 一个是用JavaScript，一次性将两个select的数据统统取出来，将第二张表的数据放到数组中，通过第一个的change事件来改变，优点，运行速度快，缺点，需编写对应的javascript代码，且无法反映实时数据 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 第二种方案是每次都提交，进行联动，优点，能反映数据库实时数据信息，无须写javascript,缺点，运行速度相对慢，且需要考虑保存用户的已经填写的其他表单数据 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 看我的，方便 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &lt;form &nbsp; name="form1" &nbsp; method="post"&gt; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; width="40%"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select&gt; &nbsp; <br>&nbsp; &lt;% &nbsp; <br>&nbsp; try{ &nbsp; <br>&nbsp; Connection &nbsp; con=j.getConnection(); &nbsp; <br>&nbsp; Statement &nbsp; statement=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); &nbsp; <br>&nbsp; String &nbsp; sql="select &nbsp; * &nbsp; from &nbsp; table"; &nbsp; <br>&nbsp; ResultSet &nbsp; r=statement.executeQuery(sql); &nbsp; <br>&nbsp; while(r.next()) &nbsp; <br>&nbsp; { &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option &nbsp; value=&lt;%=r.getString(1)%&gt;&gt;&lt;%=r.getString(1)%&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &lt;%} &nbsp; <br>&nbsp; j.releaseConnection(con); &nbsp; <br>&nbsp; }catch(SQLException &nbsp; ee){out.print("数据库连接失败！");} &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br><br>&lt;%@ &nbsp; page &nbsp; contentType="text/html;charset=gb2312"%&gt; &nbsp; &nbsp; <br>&nbsp; &lt;%@ &nbsp; page &nbsp; import="java.sql.*"%&gt; &nbsp; <br>&nbsp; &lt;%@ &nbsp; page &nbsp; import="java.io.*"%&gt; &nbsp; <br>&nbsp; &lt;jsp:useBean &nbsp; id="user" &nbsp; class="com.conn_" &nbsp; scope="page"/&gt; &nbsp; <br>&nbsp; &lt;% &nbsp; <br>&nbsp; String &nbsp; las &nbsp; =request.getParameter("la"); &nbsp; <br>&nbsp; String &nbsp; ars &nbsp; =request.getParameter("ar"); &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &lt;html&gt; &nbsp; <br>&nbsp; &lt;head&gt; &nbsp; <br>&nbsp; &lt;meta &nbsp; http-equiv="Content-Type" &nbsp; content="text/html; &nbsp; charset=gb2312"&gt; &nbsp; <br>&nbsp; &lt;script &nbsp; language="javascript"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; yjchang(){ &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; document.form2.la.value=document.form1.la.value; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.form2.submit(); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; <br>&nbsp; &lt;/script&gt; &nbsp; <br>&nbsp; &lt;/head&gt; &nbsp; <br>&nbsp; &lt;body&gt; &nbsp; <br>&nbsp; &lt;form &nbsp; action="xx_add.jsp" &nbsp; method=post &nbsp; name="form2"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input &nbsp; type="hidden" &nbsp; name="la" &nbsp; id="la" &nbsp; value="&lt;%=las%&gt;"&gt; &nbsp; <br>&nbsp; &lt;input &nbsp; type="hidden" &nbsp; name="ar" &nbsp; id="ar" &nbsp; value="&lt;%=ars%&gt;"&gt; &nbsp; <br>&nbsp; &lt;/form&gt; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &lt;form &nbsp; name="form1" &nbsp; method="post" &nbsp; action="xx_add_do.jsp"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &lt;br/&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &lt;table &nbsp; width="80%" &nbsp; &nbsp; border="0" &nbsp; align="center" &nbsp; cellpadding="1" &nbsp; cellspacing="1" &nbsp; class="table1"&gt; &nbsp; <br>&nbsp; &nbsp; &lt;tr&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; width="16%" &nbsp; height="40" &nbsp; align="right"&gt;部门：&lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; height="40"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;select &nbsp; name="la" &nbsp; id="la" &nbsp; style="width:147" &nbsp; onChange="yjchang()"&gt; &nbsp; <br>&nbsp; &lt;option&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &lt;% &nbsp; <br>&nbsp; &nbsp; &nbsp; String &nbsp; la1=request.getParameter("la"); &nbsp; <br>&nbsp; String &nbsp; la=""; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; ResultSet &nbsp; rs_la=null; &nbsp; <br>&nbsp; &nbsp; &nbsp; try{ &nbsp; <br>&nbsp; &nbsp; &nbsp; rs_la=user.executeQuery("select &nbsp; branch_id,name &nbsp; from &nbsp; branch"); &nbsp; <br>&nbsp; while(rs_la.next()){ &nbsp; <br>&nbsp; la=""; &nbsp; <br>&nbsp; if(rs_la.getString("branch_id").equals(la1)){ &nbsp; <br>&nbsp; la="selected"; &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option &nbsp; value="&lt;%=rs_la.getString("branch_id")%&gt;" &nbsp; &lt;%=la%&gt;&gt;&lt;%=rs_la.getString("name")%&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% &nbsp; <br>&nbsp; }else{ &nbsp; <br>&nbsp; &nbsp; &nbsp; la=""; &nbsp; <br>&nbsp; &nbsp; &nbsp; %&gt; &nbsp; <br>&nbsp; &lt;option &nbsp; value="&lt;%=rs_la.getString("branch_id")%&gt;"&gt;&lt;%=rs_la.getString("name")%&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &lt;%}} &nbsp; <br>&nbsp; }catch( &nbsp; SQLException &nbsp; sqle &nbsp; ){} &nbsp; <br>&nbsp; catch( &nbsp; Exception &nbsp; e &nbsp; ){} &nbsp; <br>&nbsp; finally{ &nbsp; <br>&nbsp; try{ &nbsp; <br>&nbsp; user.getClose(); &nbsp; <br>&nbsp; if &nbsp; (rs_la &nbsp; !=null){ &nbsp; <br>&nbsp; rs_la.close(); &nbsp; <br>&nbsp; rs_la=null; &nbsp; <br>&nbsp; } &nbsp; <br>&nbsp; }catch( &nbsp; SQLException &nbsp; sqle &nbsp; ){} &nbsp; &nbsp; <br>&nbsp; } &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; height="40" &nbsp; align="right"&gt;员工：&lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; height="40"&gt; &nbsp; <br>&nbsp; &lt;select &nbsp; name="ar" &nbsp; id="ar" &nbsp; style="width:147"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% &nbsp; <br>&nbsp; if(las!=null){ &nbsp; <br>&nbsp; String &nbsp; ar1=request.getParameter("ar"); &nbsp; <br>&nbsp; String &nbsp; ar=""; &nbsp; <br>&nbsp; ResultSet &nbsp; rs_area=null; &nbsp; <br>&nbsp; try{ &nbsp; <br>&nbsp; rs_area=user.executeQuery("select &nbsp; ygid,name &nbsp; from &nbsp; hyj.area &nbsp; where &nbsp; branch_id='"+las+"'"); &nbsp; <br>&nbsp; while(rs_area.next()){ &nbsp; <br>&nbsp; &nbsp; ar=""; &nbsp; <br>&nbsp; &nbsp; if(rs_area.getString("ygid").equals(ar1)){ &nbsp; <br>&nbsp; &nbsp; ar="selected"; &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option &nbsp; value="&lt;%=rs_area.getString("ygid")%&gt;" &nbsp; &lt;%=ar%&gt;&gt;&lt;%=rs_area.getString("name")%&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%}else{%&gt; &nbsp; <br>&nbsp; &lt;option &nbsp; value="&lt;%=rs_area.getString("ygid")%&gt;"&gt;&lt;%=rs_area.getString("name")%&gt;&lt;/option&gt; &nbsp; <br>&nbsp; &lt;%}} &nbsp; <br>&nbsp; }catch( &nbsp; SQLException &nbsp; sqle &nbsp; ){} &nbsp; <br>&nbsp; catch( &nbsp; Exception &nbsp; e &nbsp; ){} &nbsp; <br>&nbsp; finally{ &nbsp; <br>&nbsp; try{ &nbsp; <br>&nbsp; user.getClose(); &nbsp; <br>&nbsp; if &nbsp; (rs_area &nbsp; !=null){ &nbsp; <br>&nbsp; rs_area.close(); &nbsp; <br>&nbsp; rs_area=null; &nbsp; <br>&nbsp; } &nbsp; <br>&nbsp; }catch( &nbsp; SQLException &nbsp; sqle &nbsp; ){} &nbsp; &nbsp; <br>&nbsp; } &nbsp; <br>&nbsp; %&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/select&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr &nbsp; align="center"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td &nbsp; height="40" &nbsp; colspan="4"&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &lt;input &nbsp; type="Submit" &nbsp; name="tj" &nbsp; value="提交" &nbsp; class="button"&gt; &nbsp; <br>&nbsp; &amp;nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input &nbsp; type="reset" &nbsp; name="Submit" &nbsp; value="重置" &nbsp; class="button"&gt; &nbsp; <br>&nbsp; &lt;/td&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt; &nbsp; <br>&nbsp; &nbsp; &nbsp; &lt;/table&gt; &nbsp; <br>&nbsp; &lt;/form&gt; &nbsp; <br>&nbsp; &lt;/body&gt; &nbsp; <br>&nbsp; &lt;/html&gt;&nbsp;&nbsp; <br>
<img src ="http://www.blogjava.net/marsforest/aggbug/110092.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/marsforest/" target="_blank">火星的森林</a> 2007-04-12 10:21 <a href="http://www.blogjava.net/marsforest/archive/2007/04/12/110092.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>收藏：Java开发环境配置大全</title><link>http://www.blogjava.net/marsforest/archive/2006/06/21/54110.html</link><dc:creator>火星的森林</dc:creator><author>火星的森林</author><pubDate>Wed, 21 Jun 2006 00:54:00 GMT</pubDate><guid>http://www.blogjava.net/marsforest/archive/2006/06/21/54110.html</guid><wfw:comment>http://www.blogjava.net/marsforest/comments/54110.html</wfw:comment><comments>http://www.blogjava.net/marsforest/archive/2006/06/21/54110.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/marsforest/comments/commentRss/54110.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/marsforest/services/trackbacks/54110.html</trackback:ping><description><![CDATA[安装JDK<br />　　<br />　　从<a href="http://Java.sun.com/">http://Java.sun.com/</a>下载jdk-1_5_0_04-windows-i586-p.exe<br />　　<br />　　安装到指定路径，如选择D:\jdk1.5.0<br />　　<br />　　配置环境变量：<br />　　<br />　　Java_HOME: D:\jdk1.5.0<br />　　PATH: D:\jdk1.5.0\bin;<br />　　CLASSPATH: .;D:\jdk1.5.0\lib\tools.jar;<br />　　D:\jdk1.5.0\jre\lib\rt.jar;<br />　　<br />　　安装WTK<br />　　<br />　　从<a href="http://Java.sun.com/">http://Java.sun.com/</a>下载j2me_wireless_toolkit-2_2-windows.exe<br />　　<br />　　安装到指定路径，如选择D:\WTK22<br />　　<br />　　安装Eclipse<br />　　<br />　　从<a href="http://www.eclipse.org/">http://www.eclipse.org/</a>下载eclipse-SDK-3.0.1-win32.zip和<br />　　<br />　　NLpack-eclipse-SDK-3.0.x-win32.zip（语言包）<br />　　<br />　　解压缩eclipse-SDK-3.0.1-win32.zip即可，如路径：D:\MyDevelopTools\eclipse<br />　　<br />　　解压缩NLpack-eclipse-SDK-3.0.x-win32.zip,得到features和plugins两个文件夹，把里面的文件分别拷入eclipse中相应的目录下即可<br />　　<br />　　安装Tomcat<br />　　<br />　　从<a href="http://jakarta.apache.org/">http://jakarta.apache.org/</a>下载jakarta-tomcat-5.5.9.zip<br />　　<br />　　解压缩jakarta-tomcat-5.5.9.zip即可<br />　　<br />　　配置环境变量：<br />　　<br />　　Tomcat_Home: D:\MyDevelopTools\tomcat-5.5.9<br />　　<br />　　PATH: D:\MyDevelopTools\tomcat-5.5.9;<br />　　 在eclipse中配置J2ME开发环境：<br />　　<br />　　安装eclipseme:<br />　　<br />　　从<a href="http://www.eclipseme.org/">http://www.eclipseme.org/</a>下载eclipseme.feature_0.9.4_site.zip，在eclipse中选择帮助-〉软件更新-〉查找并安装-〉搜索要安装的新功能部件-〉新建已归档的站点。选择eclipseme.feature_0.9.4_site.zip，打开-〉选择eclipseme.feature_0.9.4_site.zip，剩下的一直下一步就可以了。安装完成会在窗口-〉首选项中出现J2ME<br />　　<br />　　修改Java-〉调试：<br />　　<br />　　选中Java-〉调试，把暂挂执行的前两项点去，通信中的调试器超时改为15000<br />　　<br />　　配置WTK<br />　　<br />　　窗口-〉首选项-〉J2ME-〉Platform Components<br />　　<br />　　右键单击对话框右侧的Wireless Toolkit，选择Add Wireless Toolkit,<br />　　<br />　　选择WTK安装目录，eclipse会自动匹配。<br />　　<br />　　在eclipse中配置J2EE开发环境(Tomcat5.5.9)：<br />　　<br />　　安装EMF-RunTime:<br />　　<br />　　从<a href="http://www.eclipseme.org/">http://www.eclipseme.org/</a>下载emf-sdo-runtime-2.0.1.zip<br />　　<br />　　解压缩emf-sdo-runtime-2.0.1.zip,得到features和plugins两个文件夹，把里面的文件分别拷入eclipse中相应的目录下即可。<br />　　<br />　　安装Lomboz：<br />　　<br />　　从<a href="http://forge.objectweb.org">http://forge.objectweb.org</a>下载org.objectweb.lomboz_3.0.1.N20050106.zip解压缩org.objectweb.lomboz_3.0.1.N20050106.zip,得到features和plugins两个文件夹，把里面的文件分别拷入eclipse中相应的目录下。如果在窗口-〉首选项中有Lomboz选项就安装正确，如果没有，在D:\eclipse\configuration\下删除org.eclipse.update这个文件夹,再重起eclipse就可以了。<br />　　<br />　　配置Lomboz:<br />　　<br />　　在D:\eclipse\plugins\com.objectlearn.jdt.j2ee_3.0.1\servers下新建一个文件tomcat559.server，里面的内容从tomcat50x.server全部复制过来，把name="Apache Tomcat v5.0.x"替换成name="Apache Tomcat v5.5.9"，然后把所有的<br />　　<br />　　“${serverRootDirectory}/bin;${serverRootDirectory}/common/endorsed”替换成<br />　　<br />　　“${serverRootDirectory}/common/endorsed”就可以了。然后进入eclipse，窗口-〉首选项-〉Lomboz，把JDK Tools.jar改为：D:\jdk1.5.0\lib\tools.jar，窗口-〉首选项-〉Lomboz-〉Server Definitions,在Server types中选择Tomcat5.5.9在Application Server Directory和Classpath Variable的路径改为D:/MyDevelopTools/tomcat-5.5.9先应用，再确定就可以了。 <br /><img src ="http://www.blogjava.net/marsforest/aggbug/54110.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/marsforest/" target="_blank">火星的森林</a> 2006-06-21 08:54 <a href="http://www.blogjava.net/marsforest/archive/2006/06/21/54110.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>