??xml version="1.0" encoding="utf-8" standalone="yes"?>极品白浆推特女神在线观看 ,在线日韩影院,夜夜精品视频http://www.aygfsteel.com/mstar/category/2359.html搞Y件开发就像被强奸,如果不能反抗,׃n受它吧!zh-cnTue, 27 Feb 2007 18:34:38 GMTTue, 27 Feb 2007 18:34:38 GMT60用DWR2.0做的一个Server日志查看?/title><link>http://www.aygfsteel.com/mstar/archive/2007/01/03/Ajax_DWR2_LogViewer.html</link><dc:creator>黑灵</dc:creator><author>黑灵</author><pubDate>Wed, 03 Jan 2007 14:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/mstar/archive/2007/01/03/Ajax_DWR2_LogViewer.html</guid><wfw:comment>http://www.aygfsteel.com/mstar/comments/91645.html</wfw:comment><comments>http://www.aygfsteel.com/mstar/archive/2007/01/03/Ajax_DWR2_LogViewer.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mstar/comments/commentRss/91645.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mstar/services/trackbacks/91645.html</trackback:ping><description><![CDATA[ <p>有时候我需要查看已l部|到服务器上的应用程序的日志Q每ơ都要远E登录服务器感觉很麻烦,所以一般我会把log文g的目录用apache做个|站Q这样通过IE可以访问到了。但是有时要看即时输出情况,p不断的F5Q很ȝ。所以就有个xQ不如用DWR2.0的反转Ajax来做个程序,让日志有变化时自动的发送到客户端,q样我一个劲的按F5了?br /><br />我下面就把这个程序分享给大家Q希望大家提提意见?br /><br />首先是环境:<br />DWR 2.0.rc1<br />Sun JDK 1.5<br /><br />先看张运行v来的囑֐Q大家一看就知道q是个什么东西了?br /><img height="509" alt="logviewer.png" src="http://www.aygfsteel.com/images/blogjava_net/mstar/pics2007/logviewer.png" width="776" border="0" /><br />你可以制定要监视的log文gQ当然有哪些文g文g可以被监视,你必d服务端的xml配置中文件设|,当然你也可以监视一个目录里的log文gQ这对于而log文g是每天生成一个的情况很有用。你可以讑֮在浏览器上显C的行数Q操作行敎ͼ屏幕会自动滚动。你q可以添加一些过滤器Q过滤掉不想看见的行Q我目前只做了到了过滤掉一些信息,当然如果你有兴趣Q你也再d一些更复杂的过滤器。过滤器的模式是用正则表辑ּ表示的?br /><br />下面是点几Z开始监听”,q行后样?br /><img height="598" alt="logviewer2.png" src="http://www.aygfsteel.com/images/blogjava_net/mstar/pics2007/logviewer2.png" width="776" border="0" /><br />如果服务器上的catalina.2006-12-09.log文g发生变化Q客L的浏览器上log昄Z会自动的向上滚动?br /><br /><br />下面我就大致的介l一下如何用DWR2.0来实现这L功能。在q里介绍的可能不是很详细Q不清楚的地方请看我提供的源码?br /><br />先来介绍一下目录结?br />├─lib  -- ~译和测试用的第三方cd<br />├─webapp -- 部v目录<br />├─test -- 试E序<br />├─java -- ȝ?br />└─build.xml -- ant构徏文g<br /><br />webapp下的文g和目?br />│?style.css  -- 样式表文?br />│?index.html -- ȝ面文?br />?br />├─WEB-INF<br />│?│?web.xml -- 部v配置文g<br />│?│?dwr.xml -- dwr的配|文?br />│?│?conf.xml -- 我们q个应用E序配置文gQ主要是配置log文g<br />│??br />│?├─classes <br />│??br />│?└─lib <br />?br />└─script -- javascript文g<br /><br /><br />index.html中就是我们上面的囄上能看到的页面元素。其中的控g的事件处理都写在\script\logviewer.js文g中?br /></p> <p>当页面加载时执行startPoll()ҎQ复杂开始与服务器的通信Qƈ且把log文g选择框初始化Q把已经dqo器列表显C出来?</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> startPoll() {<br />    DWREngine.setActiveReverseAjax(</span> <span style="COLOR: #0000ff">true</span> <span style="COLOR: #000000">);<br /><br />    LogManager.getLogFileNames(</span> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> (data) {<br />        DWRUtil.removeAllOptions(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">log_file</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br />        DWRUtil.addOptions(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">log_file</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">, data);<br />    });<br /><br />    LogManager.getFilters(</span> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000">(data) {<br />        </span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000"> (</span> <span style="COLOR: #0000ff">var</span> <span style="COLOR: #000000"> i </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">; i </span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000"> data.length; i</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">) {<br />            addFilterDiv(data[i].pattern, data[i].id);<br />        }<br />    });<br />}</span> </div> <p> <br />当点几Z开始监听”按钮时调用服务端的LogManager的sendҎQ服务端开启监听线E,开始监听做为参C递的文gQ如果文件有变动׃把最q增加的行发送到览器上来?<br /></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">var</span> <span style="COLOR: #000000"> startWatch </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000">() {<br />    clearLog();<br />    LogManager.send(DWRUtil.getValue(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">log_file</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">));<br />}</span> </div> <p> <br /> </p> <p>当点几Z结束监听”按钮,调用LogManager的stop()ҎQ结束掉监听U程?br /></p> <p> </p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> stopWatch() {<br />    LogManager.stop();<br />}</span> </div> <p> </p> <p> <br />当点几Z清I日志”按钮,清除mainPanel中的所有子元素</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> clearLog() {<br />    </span> <span style="COLOR: #0000ff">var</span> <span style="COLOR: #000000"> mainPanel </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> $(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">main_panel</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br />    </span> <span style="COLOR: #0000ff">while</span> <span style="COLOR: #000000"> (mainPanel.hasChildNodes()) {<br />        mainPanel.removeChild(mainPanel.firstChild);<br />    }<br />}</span> </div> <p>当点几Z添加过滤器”,填充输入框,要求输入做ؓqo器的正则表达式,输入完成后,要做两g事:<br />1、LogManager.addFilterҎQ把输入的正则表辑ּ传送给服务端?br />2、把q个正则表达式添加到面上?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> addFilter() {<br />    </span> <span style="COLOR: #0000ff">var</span> <span style="COLOR: #000000"> regex </span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> prompt(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">输入正则表达?/span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">, </span> <span style="COLOR: #000000">""</span> <span style="COLOR: #000000">);<br />    </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000"> (regex </span> <span style="COLOR: #000000">!=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000"> regex </span> <span style="COLOR: #000000">!=</span> <span style="COLOR: #000000"> </span> <span style="COLOR: #000000">""</span> <span style="COLOR: #000000">) {<br />        LogManager.addFilter(regex, </span> <span style="COLOR: #0000ff">function</span> <span style="COLOR: #000000"> (filterId) {<br />            addFilterDiv(regex, filterId);<br />        });<br />    }<br />}</span> </div>注意q里Q我们用CDWR的回调模式,在调用服务端ҎLogManager.addFilter成功后我们才调用客户端的addFilterDivҎ把这个输入的正则表达式显C到面上?br /><br />如果你够细心的话,应该会发现在q个js文g中有一个叫做addNewLine的方法在index.html中是没有被调用的。这个方法其实是l服务端的LogManager.send函数调用的?br /><br />上面q些内容是服务端脚本的主要内容了,其实很简单。主要负责通过DWR与服务端通信和处理页面显C?br /><br />下面介绍服务端的核心c:LogManager<br /><br />q个cM要就q样几个ҎQ?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">   </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 停止监控<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> stop() {<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (watcher </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) {<br />            watcher.halt();<br />        }<br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 发送log信息<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> send(String filename) {<br />        WebContext wctx </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> WebContextFactory.get();<br />        </span><span style="COLOR: #0000ff">final</span><span style="COLOR: #000000"> ScriptSession scriptSession </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> wctx.getScriptSession();<br />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (watcher </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) {<br />            watcher.halt();<br />        }<br /><br />        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br />            watcher </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> LogFileWatcher(filename);<br />            watcher.addListener(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> LogUpdateListener() {<br />                </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> onLogUpdate(List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> lines) {<br />                    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (String line : lines) {<br />                        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (checkFilters(line)) {<br />                            ScriptBuffer scriptBuffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ScriptBuffer();<br />                            scriptBuffer.appendScript(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">addNewLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)<br />                                    .appendData(line)<br />                                    .appendScript(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />                            scriptSession.addScript(scriptBuffer);<br />                        }<br />                    }<br />                }<br />            });<br />            watcher.start();<br />        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (IOException e) {<br />            ScriptBuffer scriptBuffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ScriptBuffer();<br />            scriptBuffer.appendScript(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">addNewLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)<br />                    .appendData(e.getMessage())<br />                    .appendScript(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />            scriptSession.addScript(scriptBuffer);<br />            log.warn(e);<br />        }<br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 取得指定的日志文件\?br />     *<br />     * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> 指定的日志文件\?br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> getLogFileNames() {<br />        List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> filenames </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">();<br />        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br />            XMLConfiguration config </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> getConfiguration();<br />            List logfiles </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> config.getList(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">log-files.file</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (Object o : logfiles) {<br />                filenames.add((String) o);<br />            }<br />        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (ConfigurationException e) {<br />            log.warn(e);<br />        }<br /><br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> filenames;<br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 取得指定的日志目录下的文?br />     *<br />     * </span><span style="COLOR: #808080">@return</span><span style="COLOR: #008000"> 指定的日志目录下的文?br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> getLogFileNamesFromDir() {<br />        List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> filenames </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">();<br />        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br />            XMLConfiguration config </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> getConfiguration();<br />            String dir </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> config.getString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">log-dir.dir</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (dir </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) {<br />                File rootDir </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> File(dir);<br />                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (rootDir.exists()) {<br />                    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (rootDir.isFile()) {<br />                        filenames.add(rootDir.getPath().replace(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\\</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">));<br />                    } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (rootDir.isDirectory()) {<br />                        String patternString </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> config.getString(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">log-dir.filter</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />                        File[] files;<br />                        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (patternString </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">patternString.equals(</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">)) {<br />                            files </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> rootDir.listFiles(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> LogFileFilter(patternString));<br />                        } </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> {<br />                            files </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> rootDir.listFiles();<br />                        }<br /><br />                        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (File file : files) {<br />                            filenames.add(file.getPath().replace(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\\</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">));<br />                        }<br />                    }<br />                }<br />            }<br />        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (ConfigurationException e) {<br />            log.warn(e);<br />        }<br /><br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> filenames;<br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * d一个过滤器Q返回过滤器的id<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> addFilter(String regex) {<br />        </span><span style="COLOR: #0000ff">synchronized</span><span style="COLOR: #000000"> (filters) {<br />            Filter filter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Filter(regex, SequenceGenerator.getInstance().next(), FilterType.INCLUDE);<br />            filters.add(filter);<br />            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> filter.getId();<br />        }<br /><br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * Ҏid删除一个过滤器<br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> removeFilter(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> id) {<br />        </span><span style="COLOR: #0000ff">synchronized</span><span style="COLOR: #000000"> (filters) {<br />            filters.remove(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Filter(id));<br />        }<br />    }<br /><br />    </span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br />     * 取得现在所有的qo器列?br />     </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Map</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String, Object</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000"> getFilters() {<br />        List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Map</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String, Object</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000"> result </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Map</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String, Object</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">();<br />        </span><span style="COLOR: #0000ff">synchronized</span><span style="COLOR: #000000"> (filters) {<br />            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (Filter filter : filters) {<br />                Map</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String, Object</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> filterItem </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> HashMap</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String, Object</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">();<br />                filterItem.put(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">id</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, filter.getId());<br />                filterItem.put(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pattern</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, filter.getPattern().pattern());<br />                result.add(filterItem);<br />            }<br />        }<br />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> result;<br />    }</span></div><br />对于大家都做qJava的朋友来_q些代码应该很容易就能看懂,我就不多说了。大家主要注意一下ScriptSessionc,q个cd是vC要功能的cM?br /><br />其中的LogFileWatcher是一个Threadc,它是用来监视log文g的?br /><br />SequenceGenerator.java是用来生成过滤器的id的?br /><br />LogUpdateListener.java是一个接口,用于实现事g回调的?br /><br />然后看一个dwr的配|文?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">dwr</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">allow</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">create </span><span style="COLOR: #ff0000">creator</span><span style="COLOR: #0000ff">="new"</span><span style="COLOR: #ff0000"> javascript</span><span style="COLOR: #0000ff">="LogManager"</span><span style="COLOR: #ff0000"> scope</span><span style="COLOR: #0000ff">="session"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">param </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="class"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">="org.devside.logviewer.LogManager"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="send"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="stop"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="getLogFileNames"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="getLogFileNamesFromDir"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="addFilter"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="removeFilter"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">include </span><span style="COLOR: #ff0000">method</span><span style="COLOR: #0000ff">="getFilters"</span><span style="COLOR: #0000ff">/></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">create</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">allow</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">dwr</span><span style="COLOR: #0000ff">></span></div><br />q里的配|文件和1.x几乎没什么两P是scope我这里设|成了session范围的。这样就可以多个人同时监视不同的log文g了?br /><br />web.xml文g也基本上是老样?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff"><?</span><span style="COLOR: #ff00ff">xml version="1.0" encoding="UTF-8"</span><span style="COLOR: #0000ff">?></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">web-app </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="LogViewer"</span><span style="COLOR: #ff0000"> version</span><span style="COLOR: #0000ff">="2.4"</span><span style="COLOR: #ff0000"><br />         xmlns</span><span style="COLOR: #0000ff">="http://java.sun.com/xml/ns/j2ee"</span><span style="COLOR: #ff0000"><br />         xmlns:xsi</span><span style="COLOR: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="COLOR: #ff0000"><br />         xsi:schemaLocation</span><span style="COLOR: #0000ff">="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">display-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">Web Log Viewer</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">display-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br /><br />    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">description</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">Direct Web Remoter Servlet</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">description</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">display-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">DWR Servlet</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">display-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">dwr-invoker</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">org.directwebremoting.servlet.DwrServlet</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">debug</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">true</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">pollAndCometEnabled</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">true</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">load-on-startup</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">1</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">load-on-startup</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br /><br />    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">dwr-invoker</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">/dwr/*</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br /><br />    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">welcome-file-list</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">welcome-file</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000">index.html</span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">welcome-file</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br />    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">welcome-file-list</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">web-app</span><span style="COLOR: #0000ff">></span></div>dwr的包名发生了变化Qƈ且要开启反转ajaxQ就要把<span style="COLOR: #000000">pollAndCometEnabled参数讄为true?br /><br />ȝQM来说DWR2.0中的反{ajaxq是很容易用的Q这也是dwr的一贯风|不用知道q多的细节就能容易的实现ajax。dwrl对是Java开发者的首选ajax框架?br />另外我这个程序其实还是ؓ了演C用的,如果惌用户实际开发可能还需要修改,比如安全性上面,性能上面。而性能上面的主要问题是客户端浏览器Q如果服务端的log文gq大Q而浏览器有不能即时的回收内存Q就会造成客户端浏览器内存占用q大而死掉的问题。而服务端׃java的内容回收机制已l比较成熟应该不会有什么问题。我在ie6和firefox2都试q了Qfirefox效果能好一些?br /><br />源码下蝲Q?br /><a href="/Files/mstar/LogViewer.part1.rar">http://www.aygfsteel.com/Files/mstar/LogViewer.part1.rar</a><br /><a href="/Files/mstar/LogViewer.part2.rar">http://www.aygfsteel.com/Files/mstar/LogViewer.part2.rar</a></span><img src ="http://www.aygfsteel.com/mstar/aggbug/91645.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mstar/" target="_blank">黑灵</a> 2007-01-03 22:21 <a href="http://www.aygfsteel.com/mstar/archive/2007/01/03/Ajax_DWR2_LogViewer.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>把DWR的配|写到Spring的配|文仉QSpring2 新特?自定义schema初体验) http://www.aygfsteel.com/mstar/archive/2006/11/16/81542.html黑灵黑灵Thu, 16 Nov 2006 07:50:00 GMThttp://www.aygfsteel.com/mstar/archive/2006/11/16/81542.htmlhttp://www.aygfsteel.com/mstar/comments/81542.htmlhttp://www.aygfsteel.com/mstar/archive/2006/11/16/81542.html#Feedback5http://www.aygfsteel.com/mstar/comments/commentRss/81542.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/81542.html你要知道Spring是什么,q且要知道Spring已经Z2.0的版本了?br />你要知道DWR是什么,q且要知道DWR也要?.0的版本了?br />
呵呵Q开个玩W……。这q头在BlogJava上؜的,估计没几个不知道上面q两个项了?br />
好了Q现在言归正传。DWR本n提供对Spring的支持,可以直接把Spring中的Bean暴露l客L览器的Javascript调用。在dwr.xml中的写法是这LQ?br />
<dwr>
    
<allow>
        
<create creator="spring" javascript="AjaxPortalService">
            
<param name="beanName" value="AjaxPortalService"/>
            
<include method="changeWondowState"/>
            
<include method="changeWorkbenchState"/>
            
<include method="changeWindowOrder"/>
        
</create>
    
</allow>
</dwr>

q样写到也没什么,只是把项目分模块以后Q虽有的配置都写C个dwr.xml文g里面l护h比较ȝQ尤其再遇到版本理中的代码合ƈ。所以曾l我扩展了DWRQ让它可以从多个文gd配置信息。然后每个模块自׃个配|文Ӟ跟着source一赯。这样做也有问题Q就是现在Java应用E序的配|文件太多啦QSpring的配|,WebWork的配|,Hibernate的配|,DWR的配|,再加上一些杂七杂八的xml和properties。看着q些配置文g直要疯掉了?br />
正在此时Qspring2横空ZQ现在你可以把一些配|文件合q到一起了。正好趁此机会体验一下Spring2的自定义schemaҎ?br />
目标Q?br />把DWR的配|写成这P
<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx
="http://www.springframework.org/schema/tx"
    xmlns:aop
="http://www.springframework.org/schema/aop"
    xmlns:dwr
="http://www.devside.org/schema/spring/dwr"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
           http://www.devside.org/schema/spring/dwr http://www.devside.org/schema/spring/dwr.xsd"

    default-autowire
="byName">
    
    
<bean id="departmentDao" class="cn.com.legendapl.hellostruts2.dao.DepartmentDao"/>
    
<bean id="employeeDao" class="cn.com.legendapl.hellostruts2.dao.EmployeeDao"/>
    
<bean id="companyService" class="cn.com.legendapl.hellostruts2.service.CompanyService"/>
    
    
<aop:config>
        
<aop:pointcut id="companyServiceOperation" expression="execution(* cn.com.legendapl.hellostruts2.service.ICompanyService.*(..))" />
        
<aop:advisor advice-ref="txAdvice" pointcut-ref="companyServiceOperation" />
    
</aop:config>    
    
    
<bean id="ajaxCompanyProxy" class="cn.com.legendapl.hellostruts2.ajax.AjaxCompanyProxy"/>
    
    
<dwr:allow id="ajaxCompanyProxyAllow">
        
<dwr:create beanName="ajaxCompanyProxy" javascript="CompanyProxy">
            
<dwr:include method="findEmployeeById"/>
        
</dwr:create>
        
<dwr:convert converter="bean" match="cn.com.legendapl.hellostruts2.entity.*"/>
    
</dwr:allow>
</beans>


重点在这里:
    <dwr:allow id="ajaxCompanyProxyAllow">
        
<dwr:create beanName="ajaxCompanyProxy" javascript="CompanyProxy">
            
<dwr:include method="findEmployeeById"/>
        
</dwr:create>
        
<dwr:convert converter="bean" match="cn.com.legendapl.hellostruts2.entity.*"/>
    
</dwr:allow>

好了现在动手开始做?br />
原理其实很简单,现在看张图。画的不好,敬请原谅Q?br />


spring-dwr.png

从这样图中我们可以看出我们要做如下工作:
1、做一个dwr.xsdQ定义spring配置文g中的dwrq部分配|的schema?br />   要做q个需要有一定xml和xsd的知识,我也是现学现用啦Q?br />

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.devside.org/schema/spring/dwr"
    xmlns:xsd
="http://www.w3.org/2001/XMLSchema"
    xmlns:beans
="http://www.springframework.org/schema/beans"
    targetNamespace
="http://www.devside.org/schema/spring/dwr" 
    elementFormDefault
="qualified"    
    attributeFormDefault
="unqualified">

    
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
    
    
<xsd:element name="allow">
        
<xsd:complexType>
            
<xsd:complexContent>
                
<xsd:extension base="beans:identifiedType">
                    
<xsd:sequence>
                        
<xsd:element name="create" type="createType" minOccurs="0" maxOccurs="unbounded"/>                
                        
<xsd:element name="convert" type="convertType" minOccurs="0" maxOccurs="unbounded"/>                
                    
</xsd:sequence>  
                
</xsd:extension>
            
</xsd:complexContent>
        
</xsd:complexType>
    
</xsd:element>    
    
<xsd:complexType name="createType">        
        
<xsd:sequence>
            
<xsd:element name="auth" type="authType" minOccurs="0" maxOccurs="unbounded"/>
            
<xsd:element name="include" type="includeType" minOccurs="0" maxOccurs="unbounded"/>
            
<xsd:element name="exclude" type="excludeType" minOccurs="0" maxOccurs="unbounded"/>                            
        
</xsd:sequence>
        
<xsd:attribute name="beanName" type="xsd:string" use="required"/>
        
<xsd:attribute name="javascript" type="xsd:string" use="required"/>                                                
    
</xsd:complexType>   
    
    
<xsd:complexType name="convertType">
        
<xsd:attribute name="converter" type="xsd:string" use="required"/>
        
<xsd:attribute name="match" type="xsd:string" use="required"/>
    
</xsd:complexType>  
    
    
<xsd:complexType name="authType">
        
<xsd:attribute name="method" type="xsd:string" use="required"/>
        
<xsd:attribute name="role" type="xsd:string" use="required"/>
    
</xsd:complexType>
    
<xsd:complexType name="includeType">
        
<xsd:attribute name="method" type="xsd:string" use="required"/>
    
</xsd:complexType>
    
<xsd:complexType name="excludeType">
        
<xsd:attribute name="method" type="xsd:string" use="required"/>
    
</xsd:complexType>
</xsd:schema>

2、我们要做一个DWRNamespaceHandler来处理DWR的配|信息,其实里面做一件事把AllowBeanDefinitionParser注册lallow节点。因为我们dwr的配|部分根节点׃个标{allowQ所以我们就做一个用于解析allow标签的AllowBeanDefinitionParser解析器就行。如果我们的根节点还有其他的标签Q同样也要做相应的解析器?br />

public class DWRNamespaceHandler extends NamespaceHandlerSupport {

    
public void init() {
        
//把AllowBeanDefinitionParser注册到allow节点
        registerBeanDefinitionParser("allow"new AllowBeanDefinitionParser());
    }

}

其实隄是做AllowBeanDefinitionParserQ这里你需要一些DOM模型的知识,来操作配|节点的内容。然后根据内容进行处理。在q里我们Q需要做三g事:
   [1]  把配|节点的内容转换成对象模型,即AllowBeanQ其实就是一些POJO|了Q?br />   [2]  把这个AllowBean注册lSpring的ContextQ这一步是可选的。因为我们主要是把这个BeanlDWRQ当焉道给Spring一份也没什么问题?br />   [3] 把这个AllowBean注册到AllowBeanHolder?br />
3、AllowBeanHolder?br />   其实q就是个单的singletonc,整个q行期只有一个实例。它像一个容器,AllowBeanDefinitionParser往里放QDWR的Configuration再从q里取?br />
4、扩展DWR的DefaultConfigurationQ我们做一个SpringConfiguration。DWR的DefaultConfiguration是负责读取配|信息的。我们在其中加入从AllowBeanHolderd配置信息的功能即可?br />
5、扩展DWR的DWRServletQ我们做一个SpringDWRServletQ原来的DWRServlet加蝲的是DefaultConfigurationQ我们的Serlvet加蝲我们自己的SpringConfiguration卛_?br />
6、万事俱备,只欠东风啦。就是让Spring知道我们q了q些Q?br />   在META-INF目录下(如果没有在src目录下创Z个)加入spring.handlers和spring.schemas两个文g?br />   spring.handlers中的内容Q?br />   http\://www.devside.org/schema/spring/dwr=org.devside.core.support.dwr.DWRNamespaceHandler
   spring.schemas中的内容Q?br />   http\://www.devside.org/schema/spring/dwr.xsd=org/devside/core/support/dwr/dwr.xsd
   
  
注意不要写错字哦Q我一开始就写错一个字母,l果怎么调试都不能成功,q以为Spring2有问题呢?br />
ok了,下面我们可以写一个spring的配|文件来试试喽?br />
下面提供两个源码包,一个是spring-dwr的源码,一个是hellosturts2Q一个struts2+spring2+hibernate3.2的例子,其中有用到spring-dwr的例子?br />
Z减小定wQ我把jar都去掉了Qlib目录下提供了一个列表,你可以自己去扄关的jar包?br />
http://www.aygfsteel.com/Files/mstar/HelloStruts2.zip

http://www.aygfsteel.com/Files/mstar/spring-dwr.zip


黑灵 2006-11-16 15:50 发表评论
]]>
dwr?-一个例?l二) http://www.aygfsteel.com/mstar/archive/2005/08/09/9674.html黑灵黑灵Tue, 09 Aug 2005 09:56:00 GMThttp://www.aygfsteel.com/mstar/archive/2005/08/09/9674.htmlhttp://www.aygfsteel.com/mstar/comments/9674.htmlhttp://www.aygfsteel.com/mstar/archive/2005/08/09/9674.html#Feedback5http://www.aygfsteel.com/mstar/comments/commentRss/9674.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/9674.html阅读全文

黑灵 2005-08-09 17:56 发表评论
]]>
dwr?-一个例?l?http://www.aygfsteel.com/mstar/archive/2005/08/09/9673.html黑灵黑灵Tue, 09 Aug 2005 09:34:00 GMThttp://www.aygfsteel.com/mstar/archive/2005/08/09/9673.htmlhttp://www.aygfsteel.com/mstar/comments/9673.htmlhttp://www.aygfsteel.com/mstar/archive/2005/08/09/9673.html#Feedback5http://www.aygfsteel.com/mstar/comments/commentRss/9673.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/9673.html阅读全文

黑灵 2005-08-09 17:34 发表评论
]]>
dwr?-一个例?/title><link>http://www.aygfsteel.com/mstar/archive/2005/08/08/9566.html</link><dc:creator>黑灵</dc:creator><author>黑灵</author><pubDate>Mon, 08 Aug 2005 05:58:00 GMT</pubDate><guid>http://www.aygfsteel.com/mstar/archive/2005/08/08/9566.html</guid><wfw:comment>http://www.aygfsteel.com/mstar/comments/9566.html</wfw:comment><comments>http://www.aygfsteel.com/mstar/archive/2005/08/08/9566.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mstar/comments/commentRss/9566.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mstar/services/trackbacks/9566.html</trackback:ping><description><![CDATA[     摘要: 上一我主要介绍dwr的概c这一我用dwr做了个可以不h面更新的表格。运行环境:windows xp pro sp2j2sdk1.2.4_03weblogic8.1struts1.2.4开发工具eclipse3.0其实dwr和struts没有什么关p,只不q最q我们项目组在用struts作东ѝ我顺便用把我的程序徏立在Struts上。主要文件。dwr.jar--dwr的类库包strut...  <a href='http://www.aygfsteel.com/mstar/archive/2005/08/08/9566.html'>阅读全文</a><img src ="http://www.aygfsteel.com/mstar/aggbug/9566.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mstar/" target="_blank">黑灵</a> 2005-08-08 13:58 <a href="http://www.aygfsteel.com/mstar/archive/2005/08/08/9566.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>dwr?/title><link>http://www.aygfsteel.com/mstar/archive/2005/08/08/9561.html</link><dc:creator>黑灵</dc:creator><author>黑灵</author><pubDate>Mon, 08 Aug 2005 05:26:00 GMT</pubDate><guid>http://www.aygfsteel.com/mstar/archive/2005/08/08/9561.html</guid><wfw:comment>http://www.aygfsteel.com/mstar/comments/9561.html</wfw:comment><comments>http://www.aygfsteel.com/mstar/archive/2005/08/08/9561.html#Feedback</comments><slash:comments>11</slash:comments><wfw:commentRss>http://www.aygfsteel.com/mstar/comments/commentRss/9561.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/mstar/services/trackbacks/9561.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最q?/SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比较火,全世界都在讨论。于是我也掺和掺和,直接?/SPAN><SPAN lang=EN-US>XMLHttpRequest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q现在的我还没有那个水^。用</SPAN><SPAN lang=EN-US>Echo2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或?/SPAN><SPAN lang=EN-US>backbase</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q又感觉那些U?/SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>framework</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">太重量了。我要的只是一些简单的应用而已。于是寻觅的重点攑֜了一些对</SPAN><SPAN lang=EN-US>xmlhttpRequest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q行轻量U包装的代码库上了。于是我扑ֈ?/SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/SPAN><SPAN lang=EN-US>Direct Web Remoting</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的口h</SPAN><SPAN lang=EN-US>AJAX and XMLHttpRequest made easy</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Qƈ且它也基本上做到了这一炏V它提供了一个友好的框架和一些很有用?/SPAN><SPAN lang=EN-US>JavaScript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库,可以让我用v</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">更容易些。详l的信息可以C们的|站</SPAN><SPAN lang=EN-US><A >http://www.getahead.ltd.uk/dwr/</A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。顺便在介绍一个网站吧Q?/SPAN><SPAN lang=EN-US><A >http://www.ajaxmatters.com</A> </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q里也有很多关于</SPAN><SPAN lang=EN-US>Ajax</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的资源?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下面来简单介l一?/SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其实在没?/SPAN><SPAN lang=EN-US>XMLHttpRequest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有了,那时它用的是</SPAN><SPAN lang=EN-US>IFrame</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q效果很差,所以我看看了就没有?/SPAN><SPAN lang=EN-US>diao</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它。现在的</SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">主要?/SPAN><SPAN lang=EN-US>XMLHttpRequest</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q当然也可以选者用</SPAN><SPAN lang=EN-US>IFrame</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q但是不推荐?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是个</SPAN><SPAN lang=EN-US>open source software</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q授权方式是</SPAN> <SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><A ><SPAN style="COLOR: #9a1414; TEXT-DECORATION: none; text-underline: none">ASL version 2.0</SPAN></A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的。现在网站上</SPAN><SPAN lang=EN-US>examples and tutorials</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做的也不错。我根据这些东西自׃做了一个应用,在本文的后面我会详细讲到?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">现在</SPAN><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的最新版本是</SPAN><SPAN lang=EN-US>1.0RC1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。在我的试用环境相还比较稳定,没有出现什么问题?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWR</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本n以一?/SPAN><SPAN lang=EN-US>dwr.jar</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>jar</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">包存在,它的入口时一?/SPAN><SPAN lang=EN-US>Servlet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/SPAN><SPAN lang=EN-US>uk.ltd.getahead.dwr.DWRServlet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q所以要?/SPAN><SPAN lang=EN-US>web.xml</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里配|一下就可以了。具体配|看q里</SPAN><SPAN lang=EN-US><A >http://www.getahead.ltd.uk/dwr/intro.html</A></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。比较简单?/SPAN><SPAN lang=EN-US>dwr</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为我们提供了一?/SPAN><SPAN lang=EN-US>framework</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">帮我们很Ҏ的实?/SPAN><SPAN lang=EN-US>JavaScript</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>java</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之间的通信?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana"><IMG height=281 alt=howitworks.png src="http://www.aygfsteel.com/images/blogjava_net/mstar/pics/howitworks.png" width=521 border=0><BR><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>我还没有看过</FONT></SPAN><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">dwr</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的源码,具体他是怎么实现的我也不太清楚。但大致上肯定是通过</SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">xmlhttprequest</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">来调用它?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">servlet</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">然后把数据用</SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">xml</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">打包解包了。其实我觉得q部分到不是</SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">dwr</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">l我带来的最方便的地斏V最方便的地方应该是他的那些</SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">js</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的库?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">所以下面我要介l一下它的两个重?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">js</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">对象?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">DWREngine </SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">Q?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">engine.js</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中)Q?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">DWRUtil (util.js</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">)</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">DWREngine</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">中的Ҏ是基本上是关?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana">XMLHttpRequest</SPAN><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">的?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">下面中介l一?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff">DWREngine.setErrorHandler(handler)<o:p></o:p></FONT></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff"><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana">默认的错误处理时弹出一个对话框Q你可以通过q个Ҏ改变成你需要的表现形式?/SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><FONT color=#000000><FONT style="BACKGROUND-COLOR: #ffffff">DWREngine.setWarningHandler(handler)<o:p></o:p></FONT></FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #666666; FONT-FAMILY: 宋体; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>改变默认的警告处理Ş?/FONT></SPAN><SPAN lang=EN-US style="COLOR: #666666; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWREngine.beginBatch()</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Some Remote Function?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWREngine.endBatch()</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当你有几个远E调用要一赯行时Q就要用到这两个Ҏ?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果不用q两个方法,你就会发C的远E调用ƈ不以你想象的序q行?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWREngine</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中还有一些其它的ҎQ我没有用过。你可以通过</SPAN><SPAN lang=EN-US>dwr</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>js-doc</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来看。如果通过文档看不懂它是干什么用的,q</SPAN><SPAN lang=EN-US>js</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">源码Q源码的注释也是比较详细的?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>DWRUtil</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中也有一些很有用的方法。这些方法一般是~写</SPAN><SPAN lang=EN-US>js</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的辅助方法?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比如</SPAN><SPAN lang=EN-US>setValue</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/SPAN><SPAN lang=EN-US>getValue</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。大多数</SPAN><SPAN lang=EN-US>html</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标签?/SPAN><SPAN lang=EN-US>value</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性,q时你要获取或者设|它的值时q</SPAN><SPAN lang=EN-US>$(“someid?.value</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以了。但是有?/SPAN><SPAN lang=EN-US>html</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标记是没?/SPAN><SPAN lang=EN-US>value</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性的Q它的值时在标{中间Q如</SPAN><SPAN lang=EN-US><span id=”span<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chmetcnv UnitName="? SourceValue="1" HasSpace="False" Negative="False" NumberType="1" TCSC="0" w:st="on">1?/st1:chmetcnv>>some value</span></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q时你要取或讑֮的值的时候就?/SPAN><SPAN lang=EN-US>DWRUtil.setValue($(“span1?</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/SPAN><SPAN lang=EN-US>someValue)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。这样你可以在客户端动态的表现一些数据了?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q有很多很好用的ҎQ?/SPAN><SPAN lang=EN-US>dwr</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的例子中有一些说明,源码中的注释也比较详l?/SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Dwr</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">׃l到q里吧。下一,我做了个</SPAN><SPAN lang=EN-US>table</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的例子?BR><IMG style="WIDTH: 686px; HEIGHT: 618px" height=618 alt=screen.jpg src="http://www.aygfsteel.com/images/blogjava_net/mstar/pics/screen.jpg" width=802 border=0></SPAN></P><img src ="http://www.aygfsteel.com/mstar/aggbug/9561.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/mstar/" target="_blank">黑灵</a> 2005-08-08 13:26 <a href="http://www.aygfsteel.com/mstar/archive/2005/08/08/9561.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¯</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¤</a>| <a href="http://" target="_blank">Т</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƾ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ײ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ǰ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">µ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ƥ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">°Ͷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ҧ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ν</a>| <a href="http://" target="_blank">Ӷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">±</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>