dwr 传递java自定义对象

前端之家收集整理的这篇文章主要介绍了dwr 传递java自定义对象前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

web.xml

	<servlet>
		<servlet-name>dwr-invoker</servlet-name>
		<servlet-class>com.wxl.app.service.MyDwrServlet</servlet-class>
		<init-param>
			<param-name>debug</param-name>
			<param-value>true</param-value>
		</init-param>
		<init-param>
			<param-name>logLevel</param-name>
			<param-value>DEBUG</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>dwr-invoker</servlet-name>
		<url-pattern>/dwr/*</url-pattern>
	</servlet-mapping>

dwr.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://www.getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
	<allow>
		<convert converter="bean" match="com.wxl.app.service.Person" />
		<create creator="new" javascript="personService">
			<param name="class" value="com.wxl.app.service.PersonService" />
		</create>
	</allow>
</dwr>

java
package com.wxl.app.service;

public class Person {
	private String id;
	private String name;
	private int age;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Person [age=" + age + ",id=" + id + ",name=" + name + "]";
	}
	
}

package com.wxl.app.service;

public class PersonService {
	public Person savePerson(Person p) {
		System.out.println(p);
		return p;
	}
	
	public String test(String p) {
		System.out.println(p);
		return p;
	}
}
原文链接:https://www.f2er.com/ajax/163978.html

猜你在找的Ajax相关文章