fantasyginge
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
<
2006年11月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
統計
隨筆 - 3
文章 - 7
評論 - 8
引用 - 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(3)
給我留言
查看公開留言
查看私人留言
隨筆檔案
(3)
2006年11月 (1)
2006年10月 (1)
2006年3月 (1)
文章分類
(7)
ajax(1)
(rss)
Database(1)
(rss)
Struts(2)
(rss)
Translation(1)
(rss)
工作流之jBPM(2)
(rss)
文章檔案
(7)
2006年11月 (1)
2006年3月 (1)
2006年1月 (3)
2005年12月 (2)
收藏夾
(1)
ajax
(rss)
項目管理(1)
(rss)
friends' Blog
jeffrey
空空的Blog
Goooood links
搜索
最新評論
1.?re: 幾種開源數據庫連接池的使用感受
請查看
http://ginge.javaeye.com
有關dbcp的文章
--fantasyginge
2.?re: 幾種開源數據庫連接池的使用感受
評論內容較長,點擊標題查看
--Norvid
3.?re: Spring & DWR integration
real good
--min
4.?re: 幾種開源數據庫連接池的使用感受
@小琴
已經更新這篇文章,去掉了數字,你可以直接copy過去試,這個是我在項目中都使用過的配置
--fantasyginge
5.?re: 幾種開源數據庫連接池的使用感受
評論內容較長,點擊標題查看
--小琴
閱讀排行榜
1.?Spring & DWR integration (1128)
2.?promise is not easy(321)
3.?Don't Look back(永不言棄)(283)
評論排行榜
1.?Spring & DWR integration (1)
2.?promise is not easy(1)
3.?Don't Look back(永不言棄)(0)
Spring & DWR integration
我的集成參考了以下幾篇文章。
Bram Smeets的Your first cup of DWR…
http://bram.jteam.nl/?p=2
Dejan Bosanac的Spring and DWR revisited
http://www.oreillynet.com/onjava/blog/2005/12/spring_and_dwr_revisited.html
邢紅瑞的dwr與spring相結合
http://blogger.org.cn/blog/more.asp?name=hongrui&id=9920
1,應用的結構:
?1
dwr
?2
dwr/src/dwr.manager/UserManager.java
?3
dwr/src/applicationContext.xml
?4
dwr/src/log4j.properties
?5
dwr/WEB-INF
?6
dwr/WEB-INF/web.xml
?7
dwr/WEB-INF/dwr.xml
?8
dwr/WEB-INF/springMVC-servlet.xml
?9
dwr/WEB-INF/lib?#####dwr.jar?bsf.jar為必須?bsf.jar?將java?bean?轉換成javascript
10
/dwr/index.jsp
2,spring applicationContext配置
1)applicationContext.xml中只有一個bean
1
<?
xml?version="1.0"?encoding="UTF-8"?
?>
2
<!
DOCTYPE?beans?PUBLIC?"-//SPRING//DTD?BEAN?2.0//EN"?"http://www.springframework.org/dtd/spring-beans-2.0.dtd"
>
3
<
beans
>
4
<
bean?
id
="UserManager"
?class
="dwr.manager.UserManager"
></
bean
>
5
</
beans
>
6
(一)與Spring MVC集成:
2)spring mvc 配置:
?1
<?
xml?version="1.0"?encoding="UTF-8"?
?>
?2
<!
DOCTYPE?beans?PUBLIC?"-//SPRING//DTD?BEAN?2.0//EN"?"http://www.springframework.org/dtd/spring-beans-2.0.dtd"
>
?3
?4
<
beans
>
?5
?6
????
<
bean?
id
="htmlViewResolver"
?7
????????class
="org.springframework.web.servlet.view.InternalResourceViewResolver"
?8
????????lazy-init
="true"
>
?9
????????
<
property?
name
="prefix"
?value
="/manage/"
?
/>
10
????????
<
property?
name
="suffix"
?value
=".html"
?
/>
11
????????
<
property?
name
="order"
>
12
????????????
<
value
>
10
</
value
>
13
????????
</
property
>
14
????
</
bean
>
15
<!--
16
????<bean?id="urlMapping"
17
????????class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
18
????????lazy-init="true">
19
20
????????<property?name="lazyInitHandlers"?value="true"?/>
21
22
????????<property?name="mappings">
23
????????????<props>
24
????????????????<prop?key="/**/*.js">dwrController</prop>
25
????????????????<prop?key="exec/*">dwrController</prop>
26
????????####?????????ohter?controller
27
????????????</props>
28
????????</property>
29
????</bean>
30
????
-->
31
????
<
bean?
id
="dwrUrlMapping"
?class
="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
>
32
?????
<
property?
name
="alwaysUseFullPath"
?value
="true"
/>
33
?????
<
property?
name
="mappings"
>
34
???????
<
props
>
35
?????????
<
prop?
key
="/dwr/**/*"
>
dwrController
</
prop
>
36
???????
</
props
>
37
????
</
property
>
38
???
</
bean
>
39
????
40
??
<
bean?
id
="dwrController"
?class
=?"org.springframework.web.servlet.mvc.ServletWrappingController"
?lazy-init
="true"
>
41
????
<
property?
name
="servletClass"
>
42
??????
<
value
>
uk.ltd.getahead.dwr.DWRServlet
</
value
>
43
????
</
property
>
44
????
<
property?
name
="initParameters"
>
45
??????
<
props
>
46
????????
<
prop?
key
="debug"
>
true
</
prop
>
47
??????
</
props
>
48
????
</
property
>
49
</
bean
>
50
</
beans
>
mvc中的兩個SimpleUrlHandlerMapping的配置都是能夠可以讓dwr和spring協同工作的。
關鍵的區別在于<property name="alwaysUseFullPath" value="true"/>
3)dwr.xml的配置:
<?
xml?version="1.0"?encoding="UTF-8"
?>
<!
DOCTYPE?dwr?PUBLIC?"-//GetAhead?Limited//DTD?Direct?Web?Remoting?1.0//EN"?"http://www.getahead.ltd.uk/dwr/dwr10.dtd"
>
<
dwr
>
????
<
allow
>
??
?????????
<
create?
creator
="spring"
???????????javascript
="UserManager"
>
??????????
<
param?
name
="beanName"
?value
="UserManager"
/>
????????
</
create
>
??????
</
allow
>
</
dwr
>
4)web.xml的配置:
初始化applicationContext片斷:
<
context-param
>
<
param-name
>
contextConfigLocation
</
param-name
>
<
param-value
>
classpath:applicationContext.xml
</
param-value
>
</
context-param
>
<
listener
>
<
listener-class
>
org.springframework.web.context.ContextLoaderListener
</
listener-class
>
</
listener
>
spring mvc配置:
<!--
?spring?mvc?
-->
<
servlet
>
<
servlet-name
>
springMVC
</
servlet-name
>
<
servlet-class
>
org.springframework.web.servlet.DispatcherServlet
</
servlet-class
>
<
load-on-startup
>
1
</
load-on-startup
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>
springMVC
</
servlet-name
>
<
url-pattern
>
*.aspx
</
url-pattern
>
</
servlet-mapping
>
<
servlet-mapping
>
<
servlet-name
>
springMVC
</
servlet-name
>
<
url-pattern
>
/dwr/*
</
url-pattern
>
</
servlet-mapping
>
(二)不與spring mvc整合,僅與spring applicationContext結合:
將所有spring mvc里面關于dwr的配置都刪除。在web.xml里添加如下配置:
<
servlet
>
<
servlet-name
>
dwr
</
servlet-name
>
<
servlet-class
>
uk.ltd.getahead.dwr.DWRServlet
</
servlet-class
>
<
init-param
>
<
param-name
>
debug
</
param-name
>
<
param-value
>
true
</
param-value
>
</
init-param
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>
dwr
</
servlet-name
>
<
url-pattern
>
/dwr/*
</
url-pattern
>
</
servlet-mapping
>
整合結束。
index.jsp的代碼
<%
@?page?contentType
=
"
text/html;charset=GBK
"
?language
=
"
java
"
?
%>
<
html
>
<
head
><
title
>
Simple?jsp?page
</
title
></
head
>
<
script?
type
='text/javascript'?
src
='<%=request.getContextPath()%
>
/
dwr
/
interface
/
UserManager.js'
>
</
script
>
<
script?
type
='text/javascript'?
src
='<%=request.getContextPath()%
>
/
dwr
/
engine.js'
>
</
script
>
<
script?
type
='text/javascript'?
src
='<%=request.getContextPath()%
>
/
dwr
/
util.js'
>
</
script
>
<
script??
type
="text/javascript"
>
????
function
?showResult(b)?
{
????????
if
?(b)?
{
????????????alert(
"
已經有重復的登錄名了!
"
);
????????}
?
else
?
{
????????????alert(
"
登錄名尚未注冊過!
"
);
????????}
????}
function
?checkRepeat(s)?
{
????????
var
?o?
=
?getElement(s);
????????
if
?(o)?
{
????????????UserManager.getUser(o.value,?showResult);
????????}
????}
????
function
?getElement(name)?
{
????????
var
?result?
=
?
null
;
????????
var
?objs?
=
?document.getElementsByName(name);
????????
if
?(objs)?
{
????????????
var
?o?
=
?objs[
0
];
????????????result?
=
?o;
????????}
????????
return
?result;
????}
</
script
>
<
body
>
<
input?
type
="text"
?name
="user"
?
>
<
input?
type
="button"
?onclick
="checkRepeat('user')"
?value
="檢查是否重復"
>
</
body
>
</
html
>
posted on 2006-11-21 12:52
fantasyginge
閱讀(1128)
評論(1)
編輯
收藏
Comments
#
re: Spring & DWR integration
min
Posted @ 2007-12-07 19:39
real good
回復
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © fantasyginge
主站蜘蛛池模板:
南漳县
|
旬阳县
|
海盐县
|
宜都市
|
綦江县
|
集贤县
|
汕头市
|
凌源市
|
漳浦县
|
通江县
|
沙湾县
|
南开区
|
敦煌市
|
色达县
|
平南县
|
赤壁市
|
新余市
|
徐州市
|
青州市
|
宁武县
|
房产
|
织金县
|
无棣县
|
台北市
|
汶川县
|
华宁县
|
平塘县
|
错那县
|
宾阳县
|
凤庆县
|
鱼台县
|
微博
|
宜丰县
|
屏山县
|
岢岚县
|
长宁区
|
卢湾区
|
繁昌县
|
奉新县
|
南京市
|
安阳县
|