springside3背景struts2.1.2 spring2.5.6 Hibernate3.4GA
1.struts2
使用ZeroConfig + CodeBehind插件,實現約定大于配置的零配置文件風格.
根本不用配置struts.xml文件
這里就是action實現annotation CodeBehind。
如方法
通過 /user/user!input.action訪問, 并轉到 /user/user-xxx.jsp頁面
即namespace + action name + "-" + "xxx.jsp"
另外其中 action中需要注入的 service 使用annotation ,在set方法前 加入@request 或 @ autowired 或 @resource
注釋(具體是用那個暫時無法搞清楚,總之我用request 就不行,另外兩個都可以)
有了這個代碼之后 就能注入spring 環境中的 id = userManager 的bean (我個人理解)
而spring中 id = userManager 的bean 也是通過自動注入完成的
主要代碼是 applicationContext.xml文件中的
代碼:
2.spring
spring2.5.6的annotation特性用的比較泛濫。 新手剛開始看的一頭霧水很正常。
xml文件中配置自動注冊bean,通過掃描包中的帶注解的類。即這個代碼:
掃描到下面的類,就自動注冊成 id=userManager
3.hibernate
使用hiberante3 注解,不要XML配置,實體類注解不用多說。
需要注意的是entity類的掃描配置
看清楚是掃描包,不是掃描類! 所以實體類com.mylu.User是無法掃描到,要放在 com.mylu.xxx.User才能掃描到!
下邊按照ss3風格做的例子,去掉spring security 框架的, 結構更清晰。
下載:實例代碼
附:
類庫
posted on 2009-01-08 17:01
Super·shen BLOG 閱讀(1795)
評論(2) 編輯 收藏