dwr使用笔记 博客分类: 我的文档中心 DWRServletBeanSpringHibernate
1.配置
web.xml中加入
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>classes</param-name>
<param-value>java.lang.Object</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
如果使用hibernate,可加入
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/dwr/*</url-pattern>
</filter-mapping>
dwr.xml配置
<dwr>
<init>
<converter id="string"
class="com.util.UTF8StringConverter" />
</init>
<allow>
<!-- enum -->
<convert converter="enum" match="com.util.UserType"/>
<!-- bean -->
<convert
match="com.domain.customer.Customer"
converter="bean">
<param name="include">id,type,status,name</param>
</convert>
<create creator="spring" javascript="productService">
<param name="beanName" value="productService" />
<include method="updateProduct" />
<include method="getProductListt" />
</create>
</allow>
<signatures>
<![CDATA[
import java.util.Set;
import java.util.Map;
import com.service.MeetService;
MeetService.check(String visitorKey, String actionUrl);
]]>
</signatures>
</dwr>