基礎(chǔ)知識(shí)詳見:
http://mercyblitz.javaeye.com/blog/70106 http://mercyblitz.javaeye.com/blog/70114
這兩篇文章,寫的很詳細(xì)。
但在實(shí)際項(xiàng)目中是SSH架構(gòu)的,我們需要拿到spring bean(例如BO,DAO等)然后設(shè)計(jì)一些跟業(yè)務(wù)相關(guān)的自定義標(biāo)簽,這時(shí)就得用到spring提供的WebApplicationContextUtils,通過這個(gè)類的實(shí)例對(duì)象去取bean。
示例代碼如下:
1
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
2
IUserBO userBO = (IUserBO) wac.getBean("userBO");
3
//userBO已經(jīng)在spring配置文件中進(jìn)行配置
4
<bean id="userBO" class="com.ns.UserBO" parent="commonService">
5
</bean>
然后我們就可以在標(biāo)簽實(shí)現(xiàn)類夾雜一些業(yè)務(wù)邏輯判斷了。
trust what we trust...