DWR Advanced topic DWR with Spring integration (not using SPRINGMVC, but using annotations for instances)

Source: Internet
Author: User
Tags xmlns
DWR Advanced topic DWR with Spring integration (not using SPRINGMVC, but using annotations for instances)

----------

Xml

<?xml version= "1.0" encoding= "iso-8859-1"?> <! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "http://java.sun.com/dtd/web-app_2 _3.dtd "> <web-app id=" Dwr_dev "> <listener> <listener-class>org.springframework.web.context.c ontextloaderlistener</listener-class> </listener> <context-param> <param-name>contextco Nfiglocation</param-name> <param-value> Classpath:dwr3SampleAppSpring3AnnotNonSpringMVC.xml & lt;/param-value> </context-param> <servlet> <servlet-name>dwr</servlet-name> & Lt;servlet-class>org.directwebremoting.spring.dwrspringservlet</servlet-class> <init-param> &lt ;p aram-name>debug</param-name> <param-value>true</param-value> </init-param> &lt
;/servlet> <servlet-mapping> <servlet-name>dwr</servlet-name>     <url-pattern>/dwr/*</url-pattern> </servlet-mapping> </web-app>
 

Spring's bean configuration file

<?xml version= "1.0" encoding= "UTF-8"?> <beans
xmlns= "Http://www.springframework.org/schema/beans"
       xmlns:context= "Http://www.springframework.org/schema/context"
       xmlns:dwr= "http// Www.directwebremoting.org/schema/spring-dwr "
       xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "
       xsi : schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd
       Http://www.springframework.org/schema/context http://www.springframework.org/schema/ Context/spring-context-3.0.xsd
       Http://www.directwebremoting.org/schema/spring-dwr/http Www.directwebremoting.org/schema/spring-dwr-3.0.xsd ">
  
   <dwr:configuration/>   
   <dwr: Annotation-scan base-package= "Org.uk.ltd.dwr.dev" scandatatransferobject= "true" scanremoteproxy= "true"/>   
</beans>

Java files

Package Org.uk.ltd.dwr.dev.model;

Import Org.directwebremoting.annotations.DataTransferObject;

@DataTransferObject public
class Address {
	private String Street;
	Private String Street2;
	Private String city;
	Private String State;
	
	Public String Getstreet () {
		return street;
	}
	public void Setstreet (String street) {
		this.street = Street;
	}	
	Public String GetStreet2 () {
		return street2;
	}	
	public void SetStreet2 (String street2) {
		This.street2 = Street2;
	}
	Public String getcity () {
		return city;
	}	
	public void Setcity (String city) {
		this.city = city;
	}	
	Public String getState () {
		return state;
	}	
	public void SetState (String state) {
		this.state = state;
	}	
}

Package org.uk.ltd.dwr.dev.service;

Import Org.directwebremoting.annotations.RemoteMethod;
Import Org.directwebremoting.annotations.RemoteProxy;
Import org.uk.ltd.dwr.dev.model.Address;

@RemoteProxy (name= "Dwrservice") public
class Dwrservice {public
	
	Dwrservice () {}
	
	@RemoteMethod
	Public Address getaddress () throws Exception {
		address address = new Address ();		
		Address.setstreet ("2245 NW Overlook Drive");
		Address.setcity ("Portland");
		Address.setstate ("Oregon");
		return address;
	}
	
	@RemoteMethod public
	void Printaddress () {
		System.out.println ("Printing");
	}
}

Index.html

 





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.