DWR Annotations 使用 SpringCreator
For example:
web.xml:
<servlet>
<servlet-name>dwr-invoker</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>
<init-param>
<param-name>classes</param-name>
<param-value>
com.exjour.bean.people.UserBean,
com.exjour.bean.layer.WmsLayerBean,
com.exjour.web.handler.people.UserHandler,
com.exjour.web.handler.layer.WmsLayerHandler
</param-value>
</init-param>
</servlet>
WmsLayerHandler.java:
WmsLayerBean.java:
package com.exjour.bean.layer;
![](/Images/OutliningIndicators/None.gif)
import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;
![](/Images/OutliningIndicators/None.gif)
@DataTransferObject
public class WmsLayerBean {
![](/Images/OutliningIndicators/InBlock.gif)
private int id;
private String name;
private boolean defaultVisiable;
private String layers;
private int state;
@RemoteProperty
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@RemoteProperty
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@RemoteProperty
public boolean isDefaultVisiable() {
return defaultVisiable;
}
public void setDefaultVisiable(boolean defaultVisiable) {
this.defaultVisiable = defaultVisiable;
}
@RemoteProperty
public String getLayers() {
return layers;
}
public void setLayers(String layers) {
this.layers = layers;
}
@RemoteProperty
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}
web.xml:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
WmsLayerHandler.java:
1
package com.exjour.web.handler.layer;
2![](/Images/OutliningIndicators/None.gif)
3
import java.util.List;
4![](/Images/OutliningIndicators/None.gif)
5
import org.directwebremoting.annotations.Param;
6
import org.directwebremoting.annotations.RemoteMethod;
7
import org.directwebremoting.annotations.RemoteProxy;
8
import org.directwebremoting.spring.SpringCreator;
9![](/Images/OutliningIndicators/None.gif)
10
import com.exjour.bean.layer.WmsLayerBean;
11
import com.exjour.service.layer.WmsLayerService;
12
import com.exjour.web.handler.BaseHandler;
13![](/Images/OutliningIndicators/None.gif)
14
@RemoteProxy(creator = SpringCreator.class,
15
creatorParams = @Param(name = "beanName", value = "wmsLayerHandler"))
16
public class WmsLayerHandler extends BaseHandler {
17![](/Images/OutliningIndicators/InBlock.gif)
18
private WmsLayerService wmsLayerService;
19
20
public WmsLayerService getWmsLayerService() {
21
return wmsLayerService;
22
}
23![](/Images/OutliningIndicators/InBlock.gif)
24
public void setWmsLayerService(WmsLayerService wmsLayerService) {
25
this.wmsLayerService = wmsLayerService;
26
}
27![](/Images/OutliningIndicators/InBlock.gif)
28
@RemoteMethod
29
public List<WmsLayerBean> getWmsLayerList() {
30
return wmsLayerService.getWmsLayerList();
31
}
32
}
33![](/Images/OutliningIndicators/None.gif)
其中绿色部分为Annotations,红色部分表示使用SpringCreator,粉色部分表示使用applicationContext中的"wmsLayerHandler" bean.![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
32
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
33
![](/Images/OutliningIndicators/None.gif)
WmsLayerBean.java:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)