国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
在Spring 2中整合DWR 2
前些日子看了一篇關(guān)于在Spring 2中整合DWR 2的文章《AJAX, DWR and Spring》。最近,想動(dòng)手試一下,就下載其源代碼回來看看,依葫蘆畫瓢做了一遍。在運(yùn)行時(shí),得到XML驗(yàn)證錯(cuò)誤。經(jīng)過一翻折騰,終于把問題解決。

Spring 2基于XML Schema的配置

眾所周知,Spring 2通過XML Schema配置方式極大地簡化的其配置,而且使得第三方擴(kuò)展變?yōu)榭赡堋E渲萌缦麓a所示:

<? xml version="1.0" encoding="UTF-8" ?>
< beans xmlns ="http://www.springframework.org/schema/beans"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >    
    
   
<!-- <bean /> definitions here -->
    
</ beans >
清單1 applicationContext.xml

不知大家有沒有想過spring-beans-2.0.xsd位置在那里?其實(shí),大家可以用Eclipse打開Spring的jar包,展開META-INF,并雙擊打開其中的spring.schemas文件,內(nèi)容如下:

http\://www.springframework.org/schema/beans/spring-beans- 2.0 .xsd = org/springframework/beans/factory/xml/spring-beans- 2.0 .xsd
http\://www.springframework.org/schema/tool/spring-tool-
2.0 .xsd = org/springframework/beans/factory/xml/spring-tool- 2.0 .xsd
http\://www.springframework.org/schema/util/spring-util-
2.0 .xsd = org/springframework/beans/factory/xml/spring-util- 2.0 .xsd
http\://www.springframework.org/schema/aop/spring-aop-
2.0 .xsd = org/springframework/aop/config/spring-aop- 2.0 .xsd
http\://www.springframework.org/schema/lang/spring-lang-
2.0 .xsd = org/springframework/scripting/config/spring-lang- 2.0 .xsd
http\://www.springframework.org/schema/tx/spring-tx-
2.0 .xsd = org/springframework/transaction/config/spring-tx- 2.0 .xsd
http\://www.springframework.org/schema/jee/spring-jee-
2.0 .xsd = org/springframework/ejb/config/spring-jee- 2.0 .xsd

http\://www.springframework.org/schema/beans/spring-beans.xsd
= org/springframework/beans/factory/xml/spring-beans- 2.0 .xsd
http\://www.springframework.org/schema/tool/spring-tool.xsd
= org/springframework/beans/factory/xml/spring-tool- 2.0 .xsd
http\://www.springframework.org/schema/util/spring-util.xsd
= org/springframework/beans/factory/xml/spring-util- 2.0 .xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd
= org/springframework/aop/config/spring-aop- 2.0 .xsd
http\://www.springframework.org/schema/lang/spring-lang.xsd
= org/springframework/scripting/config/spring-lang- 2.0 .xsd
http\://www.springframework.org/schema/tx/spring-tx.xsd
= org/springframework/transaction/config/spring-tx- 2.0 .xsd
http\://www.springframework.org/schema/jee/spring-jee.xsd
= org/springframework/ejb/config/spring-jee- 2.0 .xsd
清單2 spring.schemas

從以上的文件中,可以看出XML Sechema文件在類包中位置。

DWR 2.0 RC 2中的XML Schema文件

根據(jù)上面的描述,我打開DWR的jar包中spring.schemas文件,內(nèi)容如下:

http\://www.directwebremoting.org/schema/spring-dwr- 2.0 .xsd = org/directwebremoting/spring/spring-dwr- 2.0 .xsd

然后,按照上面的路徑打開spring-dwr-2.0.xsd文件,內(nèi)容如下:

<? xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!-- 省略了版權(quán)信息 -->

< xsd:schema xmlns ="http://www.directwebremoting.org/schema/spring-dwr"
            xmlns:xsd
="http://www.w3.org/2001/XMLSchema"
            targetNamespace
="http://www.directwebremoting.org/schema/spring-dwr"
            elementFormDefault
="qualified"
            attributeFormDefault
="unqualified" >

<!-- 省略了具體的定義 -->
</ xsd:schema >
清單3 spring-dwr-2.0.xsd

文件spring-dwr-2.0.xsd告訴我們,其名稱空間應(yīng)為“http://www.directwebremoting.org/schema/spring-dwr”,所以我們?cè)谂渲肧pring 2時(shí),應(yīng)使用以上的名稱空間,如下面的代碼片段所示:

<? xml version="1.0" encoding="UTF-8" ?>

< beans xmlns ="http://www.springframework.org/schema/beans"
    xmlns:dwr
="http://www.directwebremoting.org/schema/spring-dwr"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"
>

   
< dwr:configuration >
       
< dwr:convert class ="net.blogjava.max.pws.domain.Album" type ="bean" >
           
< dwr:exclude method ="photos" />
       
</ dwr:convert >
       
< dwr:convert class ="net.blogjava.max.pws.domain.Photo" type ="bean" >
           
< dwr:exclude method ="original, poster, thumb, full, album" />
       
</ dwr:convert >
   
</ dwr:configuration >

   
< bean id ="ajaxFacade"
        class
="net.blogjava.max.pws.web.ajax.AjaxFacade" >
       
< dwr:remote javascript ="AjaxFacade" />
       
< property name ="personalWebSite" ref ="personalWebSite" />
   
</ bean >

</ beans >
清單3 ajaxContext.xml

WEB-INF/web.xml配置

通過上面的配置,我們可以省去dwr.xml配置,不過在web.xml配置dwr的Servlet時(shí),要使用新的Servlet類。配置代碼片段如下:

< servlet >
   
< servlet-name > dwr </ servlet-name >
   
< servlet-class > org.directwebremoting.spring.DwrSpringServlet </ servlet-class >
   
< init-param >
       
< param-name > debug </ param-name >
       
< param-value > true </ param-value >
   
</ init-param >
   
< load-on-startup > 1 </ load-on-startup >
</ servlet >

< servlet-mapping >
   
< servlet-name > dwr </ servlet-name >
   
< url-pattern > /dwr/* </ url-pattern >
</ servlet-mapping >
清單4 web.xml

總結(jié)

通過在Spring 2整合DWR 2配置,可以集中管理應(yīng)用程序的配置,從一定程度上解決JavaEE開發(fā)中的配置文件泛濫的問題。

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
applicationContext 中 xmlns 與 xsi:schemaLocation 含義
Spring+DWR 全注解版
spring自帶的定時(shí)任務(wù)功能,基于注解和xml配置
spring tx:advice 和 aop:config
Spring集成RabbitMQ并實(shí)現(xiàn)延遲隊(duì)列
Spring 3 MVC and JSON example
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服