dwr annotation (annotations) use and reverse call (Reverse Ajax)

Source: Internet
Author: User

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();
  }
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.