Grails and DWR
前段時間學過一點DWR,現(xiàn)在在學Grails,覺得還挺好用的,于是就想著有沒有辦法將這兩個好東西用到一起來,看了Grails的文檔,發(fā)現(xiàn)里面有這個plugin,grails的wiki里面也有介紹如何使用.
我就照著wiki上面說的一做,發(fā)現(xiàn)我一輸grails install-plugin dwr 出了一段輸出后就沒有下文了
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\hailor>cd /d D:\grails
D:\grails>cd dwrdemo
D:\grails\dwrdemo>grails install-plugin dwr
Welcome to Grails 1.0-RC2 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\grails
Base Directory: D:\grails\dwrdemo
Environment set to development
Running script C:\grails\scripts\InstallPlugin.groovy
Plugins list cache does not exist or is broken, recreating ...
Plugins list cache has expired. Updating, please wait... ...
上面還有一個Demo,不過這個demo下載得還真是夠郁悶的,下了半天才下過來,不過下過來了也要安裝dwr plugin才能用.后來經過一番探索,終于找到了正確的方法:
1,從這個網站下載那個grails-dwr-0.1.zip 包
2,切換你的程序目錄下輸入 grails install-plugin XXXXX\grails-dwr-0.1.zip 前面的XXXXXX表示你放包的目錄
3,現(xiàn)在你的dwr plugin 安裝好了
4,打開 \grails-app\conf下的BootStrap.groovy 改為(看了那個wiki,這段程序的意思也就很明了了,不同的是wiki里面的文件是DwrConfigBootStrap.groovy,不過其實沒什么兩樣 )
def init = { servletContext ->
}
def destroy = {
}
def dwrconfig={
service(name:'helloService', javascript:'HelloService') {
include('hello')
}
}
}
5,創(chuàng)建一個helloService grails create-service hello
boolean transactional = true
def hello() {
"hill is here"
}
}
6,運行 grails run-app
7,輸入這個http://localhost:8080/dwrdemo/dwr查看(沒錯的話應該會看一個HelloService);