Configuration Dwr in spring

Source: Internet
Author: User


1. Add dwr.jar files in the web-inf/lib/directory


2. Configure the servlet dwrservlet in the Web.xml file

<!--configuration Dwr-->
	<servlet>
		<servlet-name>dwr-invoker</servlet-name>
		< servlet-class>org.directwebremoting.servlet.dwrservlet</servlet-class>
		<init-param>
			<param-name>debug</param-name>
			<param-value>true</param-value>
		</init-param >
	</servlet>
	
	<servlet-mapping>
		<servlet-name>dwr-invoker</servlet-name>
		<url-pattern>/dwr/*</url-pattern>
	</servlet-mapping>

Add dwr.xml files to the web-inf/directory

<?xml version= "1.0" encoding= "UTF-8"?> <!
DOCTYPE dwr Public "-//getahead limited//dtd Direct Web Remoting 2.0//en" "Http://getahead.org/dwr/dwr20.dtd" >

& lt;dwr>
	<allow>
		<!--JavaScript is configured to
		write Userdwr.save () in the alias of the Bean when using the JS code to access the bean; Just as the UserService-bound class Userserviceimpl
		invokes the Save method, which is Userserviceimpl.save ();
	 	-->
		<create creator= "Spring" javascript= "Userdwr" >
			<!--value is the ID of the bean configured in the Spring container-->
			<param name= "Beanname" value= "UserService"/>
		</create>
		
		<!--DWR only supports JSON data formats, So in DWR we have to read the attributes in JavaBean, we have to convert them to
		JSON data format, which is the UserInfo data conversion
		 -->
		<convert match= " Com.hsit.pojo.Userinfo "converter=" Bean > 
			<!--If you have a property that you don't want to take out, you exclude it, name Exclude,value is the name of the attribute you want to exclude-->
			<param name= "exclude" value= "dept" ></param>
		</convert>
	</allow>
</dwr>



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.