First talk about annotation syntax, save dwr.xml. (Since Java 5, now the more I look at a heap of configuration files more annoying, more and more like the annotation method directly simple)
First download the latest stable version of the Dwr.jar file into your project. (Do you need anything else?) No need, DWR is so simple.
Then add the following paragraph to the Web.xml
<!--dwrservlet
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.dwrservlet</servlet-class>
<init-param>
<!--default to False, try the trial, can access http://address: Port/context/dwr to test;
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!--This is the legendary DWR reverse call switch, and the default is false--
<init-param>
<param-name>activereverseajaxenabled</param-name>
<param-val Ue>true</param-value>
</init-param>
<!--log level is not much,
<init-param>
< Param-name>loglevel</param-name>
<param-value>warn</param-value>
</init-param
<!--This piece of attention, the key to the use of DWR annotation classes are added here, 2.0 of the DWR seems to not support packet scanning, I hope to provide this function, 3.0 I have not noticed that there is no such function, and now there is no official version of the;
< Init-param>
<param-name>classes</parAm-name>
<param-value>
Org.relax.service.SectionManager,
Org.relax.service. . Entity. Section
</param-value>
</init-param>
</servlet>
<!--that's not much to say, if you don't understand, It's cool where to stay.
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-p Attern>/dwr/*</url-pattern>
</servlet-mapping>
Here to explain some of the article is Uk.ltd.getahead.dwr.DWRServlet, in fact, he just inherited a Org.directwebremoting.servlet.DwrServlet himself did nothing, so these two classes use whichever is OK (this should be to be compatible with previous version, Guess, 1.0 I did not use).
Let's look at the specific class below.
@Service
@RemoteProxy(creator = SpringCreator.class, name = "sectionManager", creatorParams = @Param(name = "beanName", value = "sectionManager"))
public class SectionManager extends DefaultEntityManager<Section, Integer> {
@Autowired
OriginCollectDataManager originCollectDataManager;
@RemoteMethod
public Section get(Integer id) {
return super.get(id);
}
@RemoteMethod
public List<Section> getAll() {
return super.getAll();
}
}