|
2007年10月22日
用戶 A 寫道: 我從實用的角度上來說 **** 框架/技術是相當爛的一個東西. 從理論上也許先進. 用戶 B 反駁道: 我不喜歡聽沒有證據的東西。不知道你指的"**** 是相當爛的一個東西"什么意思?不知道你使用****有多久?是做了具體的項目體會出來它很爛還是玩了半天就覺得它爛?能不能舉出具體的例子? 我認為 **** 很棒,因為這是我在做項目和學習的過程中體會到的。 國外有很多牛人都認為 ****很棒,牛人 XXX 從????年就已經在他的項目中使用了自己的****架構,至今有很多大型的項目都在使用這個****架構。**** 在此之上做了很多的改進,總結了框架 A 和框架 B 的不足,是經過很多考驗和實踐總結的成果,希望大家不要只花了半天時間就把它否定掉。 把 **** 替換成不同的框架/技術, 這就是當前技術推廣貼的一貫文風.  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/05/158295.html
Welcome to the home of the Spring Framework, the leading full-stack Java/JEE application framework. Led and sustained by Interface21, Spring delivers significant benefits for many projects, increasing development productivity and runtime performance while improving test coverage and application quality. Submitted by Nicole Konicki on Tue, 2007-10-30 10:38. Technical Article In this TSS article, Rod Johnson explains what Spring sets out to achieve and how it can help the community develop enterprise Java applications. Submitted by Colin Sampaleanu on Thu, 2007-11-01 16:00. News and Announcements Interface21 is pleased to offer a number of Spring Framework 2.0 and AOP training events in the upcoming period, delivered by the people who build and sustain the Spring Framework. For full details, please visit the main training information page. Here is a summary of some of the upcoming courses and venues: - North America
- Core Spring: November 6th - 9th, New York, NY
- Core Spring: November 13th - 16th, Dallas, TX
- Core Spring: November 27th - 30th, Washington, DC
- Core Spring: December 4th - 7th, San Diego, CA
- Core Spring: December 17th - 20th, Washington, DC
- Core Spring: December 17th - 20th, Boston, MA
- Core Spring: January 8th - 11th, Orlando, FL
- Core Spring: January 15th - 18th, Chicago, IL
- Core Spring: January 22nd - 25th, Seattle, WA
- Core Spring: January 29th - Feb 1st, Washington, DC (Dulles)
- Europe
- Core Spring: November 5th - 8th, Oslo, Norway
- Core Spring: November 6th - 9th, Paris, France
- Core AOP: November 15th - 16th, Malmo, Sweden
- Core Spring: November 20th - 23rd, Stuttgard, Germany
- Core Spring: November 20th - 23rd, Amsterdam, Netherlands
- Core Web Services: November 26th - 27th, Amsterdam, Netherlands
- Core Spring: November 27th - 30th, Copenhagen, Denmark
- Core AOP: December 6th - 7th, London, UK
- Core Spring: December 11th - 14th, London, UK
- Core Spring: January 15th - 18th, London, UK
- Australia/Asia/Other
- Core Spring: November 5th - 8th, Brisbane, Australia
- Core Spring: November 5th - 8th, New Delhi, India
- Core Spring: November 19th - 22nd, Bangalore, India
- Core Spring: November 20th - 23rd, Cheng Du, China
- Core Spring: December 3rd - 6th, Sydney, Australia
- Core Spring: December 10th - 13th, Melbourne, Australia
- Core Spring: December 18th - 21st, Dalian, China
... plus others Interested in a full-course of Spring during Winter? The Spring Experience 2007 conference is taking place in sunny Hollywood, Florida, from Dec. 12th-15th.
| 今天去 http://www.springframework.org/ 看了一眼, 很不幸的首頁充斥了培訓信息, 還有在中國的... 其實 Spring 的法律上的版權所有者: Interface21 公司, 是有他們自己的網站的. 不過, 開源軟件不等于放棄版權, 這個大家一定要清楚啊. 讓一個 .org 的網站充滿了這樣的信息, 真是一種悲哀. 錢, 錢, 錢....  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/06/158490.html
摘要: MyEclipse 自帶的 Hibernate 和 Spring 教程(含視頻)翻譯, 內容包括: 簡介 建議的聽眾 系統需求 開始工作 反向工程 編寫和運行 Hibernate 整合 Spring 代碼 小結 常見問題 FAQ 資源 反饋
閱讀全文 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/07/158875.html
原創講解JSP過濾器和監聽器
BeanSoft(劉長炯) 2007年11月
關于這個問題, 比較復雜的說. 不過我希望通過例子來解釋會方便理解一些.
假設有一個非常危險的任務, 是九死一生. 需要你揣著炸藥包從北平開車走高速路過保定去石家莊把鬼子的碉堡給炸了. 注意: 這個任務十分艱巨, 有可能半路炸藥爆炸. 所以出發前你需要苦練10元一本的<<鐵布衫>>, 還需要立遺囑交代一下后事. 下面是路線圖: 去時路線: 北平 ==> 高速路收費站入口(都有警察和警犬) A? ==> 保定收費站 B ==> 石家莊收費站 C ==> 炸碉堡 D ==> 轉車(剛才的車已經炸沒了) E => 回來路線: 石家莊收費站 ==> 保定收費站 ==> 高速路收費站出口(都有警察和警犬) A ==> 安全回到北平 G
那么我們先簡介可能發生的情況.? A 點有可能被警察和警犬發現, 所以你只能被扭送回北平.? 即使不被發現, 還可能出現收費時發現10個現大洋一個路口的買路錢沒帶!! 哎, 只能又回去了. 還有最慘的: 高速路入口寫著: 對不起, 到石家莊的路線因為施工不通! 只好回家等著吧. 到了B和C你可能還會被人發現帶了炸藥包, 或者發現買路費少帶了! 極有可能又被扭送回北平, 注意已經在半道了, 是不會讓你繼續到石家莊的, 所以你會被從車上逮下來, 然后轉到警車上帶回來!? 也就是從 B 或者 C 直接返回. 好了, 最佳情況就是你炸了碉堡, 也成功的返回了. 然后你可以開心的把<<鐵布衫>>扔了, 然后宣告遺囑作廢.
OK, 以上過程, 就是過濾器和監聽器的真實案例.
那么炸碉堡這個任務, 就相當于要調用 JSP 或者 Servlet 來獲得執行結果(炸碉堡 D ).? 在執行之前你需要做一些準備工作, 相當于要寫一個 監聽器 com.allanlxf.ums.web.ServiceListener 在里面你可以做一些事情例如初始化資源, 例如上文的苦練<<鐵布衫>>, 立遺囑, 這個相當于代碼中的 public void contextInitialized(ServletContextEvent sce) 這樣一個初始化事件. 那么在整個任務完成之后, 這些事情你就要考慮應該作廢了, 所以需要 public void contextDestroyed(ServletContextEvent sce) 這樣一個銷毀事件, 例如把<<鐵布衫>>扔了, 然后宣告遺囑作廢, 也就是收回資源.
那么過濾器在哪里呢? 它位于任務的 A B C 點. 注意是雙向路程都會經過的. 也就是請求和響應都會經過. 但是過濾器也會檢查不同的情況, 例如 A 點實際上有兩個過濾功能: 查炸藥包和收買路錢. 這就相當于配置了: ?? ?????? sessionFilter ???? * *.do ???? * REQUEST ???? * FORWARD ?? ? 兩個過濾功能都要檢查. 如果成功了怎么辦呢? 會繼續讓你走下一個路口, 注意不是讓你直接成功. 也就是代碼: ??????? if(session.getAttribute("user") != null || path.equals("/login"))//若用戶已經登錄并且當前路徑仍然停留在登錄頁面????? {??????????? ?????????? chain.doFilter(request, response);//繼續走下面的過濾器或者任務(不保證最終任務, 因為下個過濾器也可能讓你回來) ?????????? 只有當走到 C 點的時候, 下一步才是執行了最終的任務: 執行JSP或者Servlet. ?????? } 反過來怎么辦? 把你扭送上警車, 強行返回! 這樣你連路口 B C 和最終任務都無法訪問了. 也就是不會讓你訪問下一個過濾器和執行最終的 JSP 或者 Serlvet, 可以選擇直接返回, 或者放警車上帶回去. ?????? { ?????????? return;// 直接返回 ?????????? 或者 response.sendRedirect(request.getContextPath() + "/login.jsp");//則扭送上警車, 強行返回到警察局 ?????? }
那么在 E 點發生了什么? 也就是你可能替換掉了原來的 response 對象,? 也就是換車. 這意味著你可以在過濾器里私下修改請求和響應對象.
雖然已經不那么抽象了, 但是要理解可能還是需要耐心體會的.
===================================================================== 注: 原始問題
??? 1.請看下面一段代碼和其注釋: import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SessionFilter extends HttpFilter
{
?? public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
?????????????? throws ServletException, IOException
?? {
?????? String path = request.getServletPath();//取得該servlet的路徑名稱
?????? path = path.substring(0, path.indexOf("."));?? //獲得路徑中.之前的部分
?????? HttpSession session = request.getSession();//從請求中取得session為得是從session中讀取用戶是否登錄的標志值
?????? if(session.getAttribute("user") != null || path.equals("/login"))//若用戶已經登錄并且當前路徑仍然停留在登錄頁面
?????? {???????????
???????? *? chain.doFilter(request, response);//則將當前濾鏡加入到濾鏡鏈條當中
?????? }else//若用戶尚未成功登錄
?????? {
?????????? response.sendRedirect(request.getContextPath() + "/login.jsp");//則使用請求重定向轉到登錄頁面
?????? }???????
?? }
}
/*
* 該Filter濾鏡類所過濾的是用戶在瀏覽器中輸入的
* 當前web application的訪問路徑,通過判斷用戶是
* 否成功登錄而決定是否對訪問路徑加以限止
* 在該web application的web.xml配置文件中為
* 該filte濾鏡做了相應配置
*/
請問: 上面代碼FilterChain對象盛裝的是Filter對象, 可它是怎么工作的啊? 加*號的語句是何用意啊,不是過濾路徑嗎, 為什么要將請求與響應加入呢?
2.請看下面一段代碼:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public abstract class HttpFilter implements Filter
{
?? private FilterConfig config;
?? public void init(FilterConfig config) throws ServletException
?? {
?????? this.config = config;
?????? init();
?? }
?? public void init() throws ServletException
?? {
?? }
?? public String getInitParameter(String name)
?? {
?????? return config.getInitParameter(name);
?? }
?? public ServletContext getServletContext()
?? {
?????? return config.getServletContext();
?? }
?? public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
?????????????? throws ServletException, IOException
?? {
?????? doFilter((HttpServletRequest)request, (HttpServletResponse)response, chain);
?? }
?? public abstract void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
?????????????? throws ServletException, IOException;
?? public void destroy()
?? {
?? }
}
請問: 該類就這樣寫了一下,沒有包含任何行為,它如何完成過濾工作啊?
3.請看下面代碼: package com.allanlxf.ums.web;
import javax.servlet.*;
//import javax.servlet.http.*;
import com.allanlxf.ums.service.SystemService;
import com.allanlxf.ums.service.StudentService;
public class ServiceListener implements ServletContextListener
{
?? public void contextInitialized(ServletContextEvent sce)
?? {
?????? ServletContext application = sce.getServletContext();
?????? StudentService service = new StudentService();
?????? application.setAttribute("studentService", service);
?????? SystemService systemService = new SystemService();
?????? application.setAttribute("systemService", systemService);
?? }
?? public void contextDestroyed(ServletContextEvent sce)
?? {
?? }
}
/*
*本類是該web application的監聽器類,在該類中,
*將兩個無為本系統提供服務的兩個對象寫入到了
*application隱含對象中(這樣保證在該系統的任何
*地方都能夠取得這兩個服務類對象的引用)
*在本系統的web.xml文件中對該監聽器做了配置
*/
請問: 為什么要將服務類對象寫入到程序上下文中呢,直接創建不也一樣嗎? ???? 監聽器只有這樣的功能嗎,是否還有其它功能呢?
3.請看下面的配置文件內容:
?? ?????? sessionFilter ?????? com.allanlxf.ums.web.SessionFilter ?? ??? ?? ?????? sessionFilter ???? * *.do ???? * REQUEST ???? * FORWARD ?? ??????? ?? ?????? com.allanlxf.ums.web.ServiceListener ???
請問: 加*號的三項是什么意思?
當初老師講的時候,許多基本的原則原理尚不清楚,這些根本沒有聽明白,當然,老師也未細講,只說會用即可, 可是若不能明白其本質,用也只能用這一點兒, 怎么成呢, 希望您能夠比較詳悉的講一下. thank you very much!
 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/09/159374.html
MyEclipse 6 實戰開發講解視頻入門 6 Web 入門開發 - JSP/HTML/JDBC 登錄 本視頻介紹了開發中最難而又最容易被輕視的部分: JSP, 部分是因為很多人過分夸大了 Web 層框架例如 Struts 1 or 2, Spring MVC, JSF, Wichet 等等的作用(事實上對于編寫復雜的頁面, 這些框架都沒多大幫助). JSP 是表現層, 實際上不是那么容易做好的, 因為它綜合了 Web 層的幾乎所有技術, 包括但不限于 DHTML, JavaScript, CSS, AJAX, 緩存等. 友情提示: 下載微軟網盤文件時關閉下載工具, 否則你將得到錯誤的文件, 雙擊 EXE 會出來 DOS 窗口. 正確操作是點擊文件名后能看到顯示下載鏈接和文件大小等信息. 代碼: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/6_JSPHelloWorld.zip 445KB 視頻(第一部分): http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/MyEclipse6_6_1.exe 22分05秒 8.20MB 視頻(第二部分): http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/MyEclipse6_6_2.exe 40分26秒 10.5 MB 1. 新建 Web 項目 2. 編寫首頁,登錄提交表單頁面并加入客戶端表單驗證 JavaScript, 超鏈接CSS 3. 編寫后臺 Java 類 - 業務層(Biz Layer)和數據層(DAO) 4. 編寫 JSP, 加入必要的驗證并調用后臺業務類 5. 測試運行, 驗證登錄和退出 6. SQL 注入: 用戶輸入名字為 user' or '1' = '1 拼出的攻擊SQL為: select * from myuser where user = 'user' or '1' = '1' and password = 'abc' 視頻截圖:

 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/19/161502.html
因為本項目已經停止更新, 僅提供代碼供參考, 本人保持版權, 不提供任何擔保和技術支持. 附帶用戶貢獻排行, 頁面點擊率等多個插件. Eclipse 項目文件(兩個都在才能編譯運行) JSPWiki 項目改進版 http://beansoft.java-cn.org/download/JSPWiki2.4.71_project_src.7z 5.91 MB 插件及中文模版增強文件 http://beansoft.java-cn.org/download/JSPWikiPlugins_project_src.7z 3.11 MB 下載, 導入, 編譯及數據庫配置, 運行視頻(無聲) http://beansoft.java-cn.org/download/jspwiki_beansoft.exe 3.0 MB 環境: JDK 1.5, Eclipse 3.3, Tomcat 6.0.14, Mysql 5.0, Windows XP 圖解發布過程 真實操作以視頻為準. 
 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/20/161836.html
今天首頁看到一篇文章, 說了國人詆毀嫦娥一號的事. 也沒什么好說的, 怨天尤人是不對. 然后在上面點, 就看到了另外的一篇新聞: 奴隸般勞動,日本工會幫中國女工維權 http://news.qq.com/a/20071122/001583.htm 也許大家的忘性很大, 已經忘記了黑窯廠等等, 忘了北京方圓百里就是沒有任何現代氣息的城鄉結合部, 忘了苦苦掙扎在老家的農村的鄉親們, 忘了在溫州, 深圳打工的人. 當然, 我也是打工一員, 吃飽是沒問題, 可是也就僅此而已. 聰明人很多, 但是多數人卻很窮, 是大家不努力工作嘛? 不是. 那是什么呢? 這篇文章中日本工會的組織者說的一段話發人深思: “她們都是善良而誠實的勞動者,為了家族的責任,來到日本,決心努力勞動3年,卻在這里遭受了奴隸般的勞動生活,這是不公正的。構成社會的大部分成員都是普通勞動者,她們的權利和生活得不到保障的話,還談什么‘發展’?財富集中在一小部分人身上的時候,談‘發展’就是一種欺騙。 ” 2007年11月4日,日本廣島東部福山市的工會領袖武藤貢回復了這樣一封郵件給記者。半年多前,在他的幫助下,3名中國女工李紅慧、沈曉梅、繆秀琴與她們的日本雇主展開了長達一個多月的激烈斗爭,并成功拿回了自己應得的400多萬日元,回到她們位于蘇北農村的故鄉。..... 再摘一段人民網貼的內容: 書摘:1949年以后的蔣經國與臺灣 http://www.people.com.cn/GB/wenhua/1086/2078201.html 最近十年在臺灣任何一個有關"誰對臺灣貢獻最大"的民意調查里,蔣經國始終穩居首位。1960年代,臺灣經濟穩定累積成長,在有力的政治與社會條件中,技術官僚得以發揮最大的才干,加上國際資本和技術幾次轉移,臺灣成為有效率的接納者。到了1960年代末期,赤貧人口大幅降低,許多臺灣大學生畢業后就往美國跑,人民的生活已達小康的水平,唱歌、跳舞、打保齡球的娛樂活動如雨后春筍。如果說美國人努力影響蔣經國的看法,他們顯然沒有白費功夫,蔣經國幾次訪問美國,眼見美國生產力的強大,印象十分深刻。美國式的管理不是從上而下的教育和指令,而是法治文化中的契約精神,在這種遵守公共約定的自覺中,人人追求創新,力爭上游。這種現象對于一向習慣于蘇聯式思辨的蔣經國而言,確實耳目一新。此外,最具說服力的仍然是發展的事實本身,在美國受教育的知識菁英開始發揮影響力,他們根據所學結合臺灣的情形所制定的發展方案,確實行之有效,使得人民生活大幅改善,社會財富累積迅速。這樣的成果使得任何人都不得不重視美式管理背后的思維邏輯,一開始是經濟的,接著便是政治的。 全中國的人民, 向60年代的臺灣邁進吧! 我最希望的就是家鄉能早日出現 IT 業, 這樣我就不用背井離鄉了, 呵呵.  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/22/162489.html
這是 MyEclipse 幫助文檔中的內容的翻譯, 點擊菜單 Help -> Contents 可以看到 MyEclipse 的全部英文幫助文檔. 在線閱讀(完整內容含 Flash 動畫): http://beansoft.java-cn.org/myeclipse_doc_cn/ajaxtutorial/ 下載: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse中文文檔/ajaxtutorial.zip 1.53 MB 友情提示: 下載微軟網盤文件時關閉下載工具, 否則你將得到錯誤的文件, 雙擊 EXE 會出來 DOS 窗口. 正確操作是點擊文件名后能看到顯示下載鏈接和文件大小等信息. 翻譯: 劉長炯 BeanSoft@126.com Blog: http://www.aygfsteel.com/beansoft/ 日期: 2007-11-22 聲明: 中文文字版權歸 劉長炯 所有, 原文及相關的圖片等資源的版權歸原作者 Genuitec L.L.C 公司所有. 目錄 - 簡介
- 建議的聽眾
- 系統需求
- AJAX Debugging
- 小結
- 常見問題 FAQ
- 資源
- 反饋
本人原創 MyEclipse 6 幫助文檔中文版集中下載 http://cid-519b3f7aa2172030.skydrive.live.com/browse.aspx/Public/MyEclipse中文文檔  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/22/162498.html
近日看到各大中文網站紛紛嗆聲說 Spring 2.5 發布, 典型消息如下: 來自 Springframework 官方的消息,Spring 2.5 正式發布了。 http://www.springframework.org/node/561 該版本的主要特征包括: 對Spring2.0的平滑升級 —— Spring2.5被設計成為對Spring2.0的平滑升級,現存的代碼和配置文件不需要做任何更改。 更多XML命名空間配置 —— 新的命名空間包括和 完全支持Java 6和Java EE 5 —— Spring2.5支持Java 6和Java EE 5的所有新特性——同時也提供了對Java 1.4.2和J2EE1.3的支持。 完全支持基于注解的配置 —— 現在所有的配置都可以使用注解來實現,并且也支持 JSR250 注解。 基于注解的MVC controller —— Web Controller現在可以用如@RequestMapping這樣的注解來創建,無需實現任何接口。 對AspectJ的支持 —— 在一些環境下,增加了對AspectJ的裝載時編織支持,同時提供了一個新的bean切入點。 對OSGi的支持 —— Spring2.5框架的所有jar包都是兼容于OSGi的,以此來簡化在OSGi環境下對其的使用。 測試框架的巨大改變 —— 現在新的基于注解的測試框架已經支持TestNG和JUnit4 性能的改良 —— Spring2.5各方面的性能指標都有了顯著的改善。 沖著 完全支持基于注解的配置 這句話, 我興沖沖的下載了 Spring 2.5 以及其文檔, 企圖體驗一下 EJB 3 式的簡單快速的基于標注的開發, 然而, 遺憾的是官方文檔和消息的來源頁面: http://www.springframework.org/node/561, 沒有任何文字說到自己完全支持基于注解的配置. 我打開英文的 Reference, 仔細閱讀其中關于標注的部分, 然而遺憾的發現只是部分實現了標注, 請參考 http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-annotation-config , 簡單說就是實現了對 Autowired 和 Transaction, AOP 的標注支持, 而不是所有 bean 定義, 更不是說從此你可以不用寫 Bean 配置的 XML 文件了. 下午仔細試了半天, 企圖寫出標注配置的例子來, 也沒有成功實現不寫 bean 定義 XML 文件就能初始化 Bean 并注入所有屬性的功能(本來想做的例子是注入一個 message 的 String 屬性), 去閱讀下載的示例代碼(example目錄下的文件), 也沒有這樣的例子. 最后又發現了原來支持標注的版本在這里: http://www.jroller.com/habuma/entry/guice_vs_spring_javaconfig_a 它的名字叫 Spring JavaConfig. 最后我們再來看看原始頁面是如何介紹自己的標注的(http://www.springframework.org/node/561): Spring 2.5 enhances Spring 2.0 with many exciting new features, including: Full Java 6 and Java EE 5 support (JDBC 4.0, JTA 1.1, JavaMail 1.4, JAX-WS 2.0) Full-featured annotation-driven dependency injection, including support for 'qualifiers' (注意這里只是說完整支持標注驅動的依賴注入, 而不是 complete supported annotation of all features) Support for auto-detecting application components in the classpath and auto-configuring them as Spring managed objects A new bean name pointcut element in AspectJ pointcut expressions Built-in support for AspectJ load-time weaving based on the LoadTimeWeaver abstraction New XML configuration namespaces "context" and "jms", for maximum convenience A completely revised integration test framework, with first-class support for JUnit 4 and TestNG A new annotation-based controller model for Spring MVC supporting Servlet and Portlet environments Extended SimpleJdbcTemplate functionality, including support for named SQL parameters Officially certified WebSphere support The packaging of Spring Framework jars as OSGi-compliant bundles out of the box The ability to deploy a Spring ApplicationContext as a JCA RAR file, for headless application modules JCA 1.5 message endpoint management, for Spring-managed JMS and CCI message listeners 小小的興奮了一把, 最后又不得不歸于失望, 繼續研究 XML 文件的編寫格式吧. 希望下次看到類似消息的時候能翻譯的準確一些, 免得誤導偶等開源軟件"消費者". 當然了, 也歡迎 Spring 2.5 高人們向偶分享完全使用標注的例子代碼, 那樣的話我真是太感謝了!  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/23/162700.html
這是 MyEclipse 幫助文檔中的內容的翻譯, 點擊菜單 Help -> Contents 可以看到 MyEclipse 的全部英文幫助文檔. 在線閱讀(完整內容含 Flash 動畫): http://beansoft.java-cn.org/myeclipse_doc_cn/springintroduction/ 下載: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse中文文檔/MyEclipse Spring 快速入門.zip 2.31MB 友情提示: 下載微軟網盤文件時關閉下載工具, 否則你將得到錯誤的文件, 雙擊 EXE 會出來 DOS 窗口. 正確操作是點擊文件名后能看到顯示下載鏈接和文件大小等信息. MyEclipse Spring 入門教程 翻譯: 劉長炯 BeanSoft@126.com Blog: http://www.aygfsteel.com/beansoft/ 日期: 2007-11-26 聲明: 中文文字版權歸 劉長炯 所有, 原文及相關的圖片等資源的版權歸原作者 Genuitec L.L.C 公司所有. 目錄 - 簡介
- 建議的聽眾
- 系統需求
- Spring 介紹
- 開始工作
- 可視化項目
- 理解和運行代碼
- 修改項目
- 小結
- FAQ
- 資源
- 反饋
本人原創 MyEclipse 6 幫助文檔中文版集中下載 http://cid-519b3f7aa2172030.skydrive.live.com/browse.aspx/Public/MyEclipse中文文檔  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/27/163416.html
MyEclipse 6 實戰開發講解視頻入門 8 XFire Web Service 入門開發 本視頻根據 MyEclipse 幫助文檔制作的對應的視頻. 友情提示: 下載微軟網盤文件時關閉下載工具, 否則你將得到錯誤的文件, 雙擊 EXE 會出來 DOS 窗口. 正確操作是點擊文件名后能看到顯示下載鏈接和文件大小等信息. 代碼:http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/8_WebService.zip 29 KB 視頻: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/myeclipse6_8.exe 19分16秒 7.4 MB - 簡介 MyEclipse on XFire 1.2
- 創建 Web Service Project
- 開發簡單的 Web Service
- 發布運行項目, 顯示 WSDL
- 用 Web Service Explorer 測試
- 編寫基于 XFire API 的客戶端并運行測試
- 新建單獨的 Web Service 客戶端項目
- 根據 WSDL 和 JAXB 生成客戶端代碼
- 調用客戶端代碼并運行測試代碼
視頻截圖: 
 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/29/163907.html
本視頻根據自己翻譯的 MyEclipse 官方教材制作了對應的視頻, 視頻具體內容請參考 MyEclipse JSF 快速入門中文版. 友情提示: 下載微軟網盤文件時關閉下載工具, 否則你將得到錯誤的文件, 雙擊 EXE 會出來 DOS 窗口. 正確操作是點擊文件名后能看到顯示下載鏈接和文件大小等信息. 代碼: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/9_JSFLoginDemo.zip 9 KB 視頻: http://cid-519b3f7aa2172030.skydrive.live.com/self.aspx/Public/MyEclipse6Videos/myeclipse6_9.exe 15分31秒 6.6 MB 內容包括: 1.新建 Web Project 2. 添加 JSF 功能 3. 創建 Message Bundle 4. 創建 Managed Bean 5. 創建 userLogin.jsp 6. 創建 userLoginSuccess.jsp 7. 創建 導航規則 8. 發布并測試 9. 加入中文消息包 10. 測試 視頻截圖: 
 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/30/164166.html
研究了很久新出的 Spring 2.5, 總算大致明白了如何用標注定義 Bean, 但是如何定義和注入類型為 java.lang.String 的 bean 仍然未解決, 希望得到高人幫助. 總的來看 Java EE 5 的標注開發方式開來是得到了大家的認可了. @Service 相當于定義 bean, 自動根據 bean 的類名生成一個首字母小寫的 bean @Autowired 則是自動注入依賴的類, 它會在類路徑中找成員對應的類/接口的實現類, 如果找到多個, 需要用 @Qualifier("chineseMan") 來指定對應的 bean 的 ID.
一定程度上大大簡化了代碼的編寫, 例如一對一的 bean 映射現在完全不需要寫任何額外的 bean 定義了.
下面是代碼的運行結果: man.sayHello()=抽你丫的 SimpleMan said: Hi org.example.EnglishMan@12bcd4b said: Fuck you! 代碼: beans.xml <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config/>
<context:component-scan base-package="org.example"/>
</beans>
測試類:
import org.example.IMan; import org.example.SimpleMan; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringTest { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); SimpleMan dao = (SimpleMan) ctx.getBean("simpleMan"); System.out.println(dao.hello()); IMan man = (IMan) ctx.getBean("usMan"); System.out.println(man.sayHello()); } }
自動探測和注入bean的類:
package org.example;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service;
@Service public class SimpleMan { // 自動注入名稱為 Man 的 Bean @Autowired(required = false) @Qualifier("chineseMan") //@Qualifier("usMan") private IMan man; /** * @return the man */ public IMan getMan() { return man; }
/** * @param man the man to set */ public void setMan(IMan man) { this.man = man; }
public String hello() { System.out.println("man.sayHello()=" + man.sayHello()); return "SimpleMan said: Hi"; } }
一個接口和兩個實現類:
package org.example;
/** * 抽象的人接口. * @author BeanSoft * @version 1.0 */ public interface IMan { /** * 打招呼的抽象定義. * @return 招呼的內容字符串 */ public String sayHello(); }
package org.example;
import org.springframework.stereotype.Service;
/** * 中國人的實現. * @author BeanSoft */ @Service public class ChineseMan implements IMan {
public String sayHello() { return "抽你丫的"; }
}
package org.example;
import org.springframework.stereotype.Service;
/** * @author BeanSoft * 美國大兵 */ @Service("usMan") // 這里定義了一個 id 為 usMan 的 Bean, 標注里面的屬性是 bean 的 id public class EnglishMan implements IMan {
public String sayHello() { return this + " said: Fuck you!"; }
}

文章來源: http://www.aygfsteel.com/beansoft/archive/2007/11/30/164230.html
這個分頁代碼基于 JDBC 2.0 的滾動游標的機制, 核心觀念就是利用 ResultSet 類里面的 boolean absolute( int row ) throws SQLException 方法進行數據的跳轉. 經過測試(數據小于1萬條, SQL Server 2000), 這個方法比用復合 SQL 語句查詢分頁的方案要快很多. 詳細 JavaDoc 如下: Moves the cursor to the given row number in this ResultSet object. If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is row 1, the second is row 2, and so on. If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set. For example, calling the method absolute(-1) positions the cursor on the last row; calling the method absolute(-2) moves the cursor to the next-to-last row, and so on. An attempt to position the cursor beyond the first/last row in the result set leaves the cursor before the first row or after the last row. Note: Calling absolute(1) is the same as calling first(). Calling absolute(-1) is the same as calling last(). Parameters: row the number of the row to which the cursor should move. A positive number indicates the row number counting from the beginning of the result set; a negative number indicates the row number counting from the end of the result set Returns: true if the cursor is on the result set; false otherwise Throws: SQLException if a database access error occurs, or the result set type is TYPE_FORWARD_ONLY @since 1.2 /*
* @(#)Pager.java 1.00 2004-8-12
*
* Copyright 2004 . All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
/**
* Pager, 基于 JDBC 2.0 滾動機制的分頁程序, 在 MySQL, SQLServer, Access, Oracle 下測試通過.
* @author 劉長炯
* @version 1.0 2004-8-12
*/
public class Pager {
/** Used database connection */
Connection conn = null;
public Pager() {
}
/**
* 分頁功能, 返回當頁的數據(JDBC 2.0 實現).
*
* @param currentPage
* 當前頁面數(取值范圍: 從 1 開始有效, 0 自動改為 1)
* @param pageCount
* 每頁顯示記錄數
*
* @return a Vector - 數據列表
*/
public Vector pageData(int currentPage, int pageCount) {
Vector results = new Vector();
String tableName = "table_name";// 要處理的表格名
ResultSet rs = null;
String sql = "SELECT * FROM " + tableName;
Statement stmt = null;
try {
// TODO: open connection
// 生成可滾動的結果集表達式
stmt = conn.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
int count = recordCount(); // 總記錄數
int totalPage = (int) Math.ceil(1.0 * count / pageCount); // 總頁面數
if (currentPage <= 0) {
currentPage = 1;
}
// 超出頁碼范圍, 不返回數據
if (currentPage > totalPage) {
currentPage = totalPage;
return results;
}
if ((currentPage - 1) * pageCount > 0) {
// 移動結果集數據到當前頁
rs.absolute((currentPage - 1) * pageCount);
}
// rs.absolute(0); 在 ODBC 下會導致如下異常:java.sql.SQLException: Cursor
// position (0) is invalid
int i = 0; // Readed pages
while (rs.next() && i < pageCount) {
i++;
// TODO: Read each row and process to value object
ValueObject bean = new ValueObject();
// TODO: Read value to value object
result.add(bean);
}
} catch (Exception exception) {
System.out.println("Occur a error in " + getClass()
+ ".pageData() : " + exception.getMessage());
// exception.printStackTrace();
} finally {
closeJDBCResource(stmt);
closeJDBCResource(rs);
closeJDBCResource(conn);
}
return results;
}
/**
* 返回當前數據庫中記錄的總數.
*
* @return int 記錄總數
*/
public int recordCount() {
int allCount = -1;
String tableName = "table_name";// 要處理的表格名
String sql = "SELECT COUNT(*) FROM " + tableName;
ResultSet rs = null;
Statement stmt = null;
try {
// TODO: open connection
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
allCount = rs.getInt(1);
}
} catch (Exception exception) {
System.out
.println("Occur a error in " + getClass()
+ ".recordCount() : " + exception.getMessage());
} finally {
closeJDBCResource(stmt);
closeJDBCResource(rs);
closeJDBCResource(conn);
}
return allCount;
}
/**
* Close a jdbc resource, such as ResultSet, Statement, Connection.... All
* these objects must have a method signature is void close().
*
* @param resource -
* jdbc resouce to close
*/
public static void closeJDBCResource(Object resource) {
try {
Class clazz = resource.getClass();
java.lang.reflect.Method method = clazz.getMethod("close", null);
method.invoke(resource, null);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Test page.
* @param args
*/
public static void main(String[] args) {
// 分頁, 讀取第一頁數據, 共讀取5個記錄
Vector data = new Pager().pageData(1, 5);
// TODO: process value object, 更改類名
for(int i = 0; results != null && i < data.size(); i++) {
ValueObject bean = (ValueObject)data.get(i);
}
}
}
 文章來源: http://www.aygfsteel.com/beansoft/archive/2007/10/23/155318.html
2005 年的時候幫人收集整理修改的一份腳本級聯菜單, 沒用到 AJAX, 寫死的數據. 效果自己試試就知道了. 支持主流瀏覽器. 自己現在看看這代碼就覺得頭大... 呵呵 腳本就是腳本啊. 一段時間放下就看不懂了. <HTML> <HEAD> <TITLE>合同申請</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <SCRIPT LANGUAGE = JavaScript> /** Define object Dsy 構造器 fieldValues - 三個表單域的名稱, 可以通過 request.getParameter(xxx) 取值 defalutOptions - 默認選項 */ function Dsy(fieldValues, defalutOptions){ this.Items = {}; this.defalutOptions = defalutOptions;// 默認選項 this.fieldValues = fieldValues;// 三個表單域的名稱 } Dsy.prototype.add = function(id, iArray){ this.Items[id] = iArray; } Dsy.prototype.Exists = function(id){ if (typeof(this.Items[id]) == "undefined") return false; return true; }; Dsy.prototype.setup = function() { this.bean_change(0); } // This prototype method added by BeanSoft Studio Dsy.prototype.bean_change = function(v){ var str = "0"; for (i = 0; i < v; i++){ str += ("_" + (document.getElementById(this.fieldValues[i]).selectedIndex - 1)); }; var ss = document.getElementById(this.fieldValues[v]); // Avoid a null exception if(ss == null) return; with(ss){ length = 0; options[0] = new Option(this.defalutOptions[v], this.defalutOptions[v]); if (v && document.getElementById(this.fieldValues[v - 1]).selectedIndex > 0 || !v){ if (this.Exists(str)){ array = this.Items[str]; for (i = 0; i < array.length; i++) options[length] = new Option(array[i], array[i]); if (v) options[1].selected = true; } } if (++v < s.length){ this.bean_change(v); } } } function change(v){ dsy.bean_change(v);// Call test prototype } // Write form data string, 輸出表單腳本代碼 // dsy, object name // varName, 變量名 function toString(dsy, varName) { var str = ""; for(i = 0; i < dsy.fieldValues.length; i++) { str += "<select id=\"" + dsy.fieldValues[i] + "\" onChange=\"" + varName + ".bean_change(" + (i + 1) + ");\"></select>\r\n"; } str += "<br/>"; return str; } // 第一個對象 var dsy = new Dsy(["s1", "s2", "s3"], ["銷售方名稱", "銷售方聯系人", "聯系電話"]); var dsy1 = new Dsy(["s4", "s5", "s6"], ["最終用戶名稱", "最終用戶聯系人", "聯系電話"]); var dsy2 = new Dsy(s = ["s7", "s8", "s9"], ["廠商", "廠商銷售", "聯系電話"]); // 填入數據, 重復的代碼 dsy.add("0", ["亞信", "航天理想"]); dsy.add("0_0", ["亞信聯系人_1", "亞信聯系人_2"]); dsy.add("0_0_0", ["亞信聯系人_1聯系電話"]); dsy.add("0_0_1", ["亞信聯系人_2聯系電話"]); dsy.add("0_1", ["航天理想聯系人_1", "航天理想聯系人_2"]); dsy.add("0_1_0", ["航天理想聯系人_1聯系電話"]); dsy.add("0_1_1", ["航天理想聯系人_2聯系電話"]); dsy1.add("0", ["最終用戶1", "最終用戶2"]); dsy1.add("0_0", ["最終用戶1_聯系人1", "最終用戶1_聯系人2"]); dsy1.add("0_0_0", ["最終用戶1_聯系人1_電話"]); dsy1.add("0_0_1", ["最終用戶1_聯系人2_電話"]); dsy1.add("0_1", ["最終用戶2_聯系人1", "最終用戶2_聯系人2"]); dsy1.add("0_1_0", ["最終用戶2_聯系人1_電話"]); dsy1.add("0_1_1", ["最終用戶2_聯系人2_電話"]); dsy2.add("0", ["BEA", "Horizon"]); dsy2.add("0_0", ["張學友", "BeanSoft"]); dsy2.add("0_0_0", ["1234567890"]); dsy2.add("0_0_1", ["beansoft@126.com"]); dsy2.add("0_1", ["AAA", "BBB"]); dsy2.add("0_1_0", ["AAA_99999"]); dsy2.add("0_1_1", ["bbb_88888"]); function setup(){ // Initialize the object dsy.setup(); //依次調用 setup dsy1.setup(); dsy2.setup(); } function prints1(){ alert(document.frm.s1.value + " " + document.frm.s2.value + " " + document.frm.s3.value +"\r\n"); } //isNaN()檢查運算結果 http://tech.ccidnet.com/pub/article/c1115_a120997_p1.html </SCRIPT> </head> <body bgcolor="#E0E0E0" onload="setup()"> 多級關聯菜單: <form name="frm"> <!-- 方式1: 手工輸出 HTML 代碼, 便于排版 <select id="s1" onChange="dsy.bean_change(1);"></select> <select id="s2" onChange="dsy.bean_change(2);"></select> <select id="s3" onChange="dsy.bean_change(3);"></select> <br> <br> <br> <select id="s4" onChange="dsy1.bean_change(1);"></select> <select id="s5" onChange="dsy1.bean_change(2);"></select> <select id="s6" onChange="dsy1.bean_change(3);"></select> <br> <br> <br> <select id="s7" onChange="dsy2.bean_change(1);"></select> <select id="s8" onChange="dsy2.bean_change(2);"></select> <select id="s9" onChange="dsy2.bean_change(3);"></select> --> <SCRIPT LANGUAGE="JavaScript"> <!-- // 方式2: 腳本輸出表單 HTML 代碼, 代碼和上面注釋掉的類似 document.write(toString(dsy, "dsy")); document.write(toString(dsy1, "dsy1")); document.write(toString(dsy2, "dsy2")); //--> </SCRIPT> <input type=button name=b1 value="監測" onclick="prints1()"> </form> </body> </html>  文章來源: http://www.aygfsteel.com/beansoft/archive/2007/10/22/154898.html
|