DWR跨域访问的实现是从2.0开始的
具体配置如下:
web.xml中:
<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>
<init-param>
<param-name>allowScriptTagRemoting</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>allowGetForSafariButMakeForgeryEasier</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
其中allowScriptTagRemoting,crossDomainSessionSecurity,allowGetForSafariButMakeForgeryEasier即为跨域访问所需的配置参数
跨域访问时代码如下:
<script type='text/javascript' src='http://www.a.com/dwr/interface/Theme.js'></script>
<script type='text/javascript' src='http://www.a.com/dwr/engine.js'></script>
<script>
DWREngine.setMethod(DWREngine.ScriptTag);
Theme._path = 'http://www.a.com/dwr';
Theme.method1("param",function(result){});
</script>
标签:DWR,跨域,访问,DWREngine,crossDomainSessionSecurity,true From: https://blog.51cto.com/u_16237557/7262660