在一次使用DWR的时候,页面报 DWR无效
测试DWR:
http://127.0.0.1:8001/DWR_Demo.js
页面提示如下错误 (如果DWR是正常的应该正常显示)
java.lang.SecurityException: No class by name: DWR_Demo uk.ltd.getahead.dwr.impl.DefaultCreatorManager.getCreator(DefaultCreatorManager.java:196) uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor.handle(DefaultInterfaceProcessor.java:54) uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:77) uk.ltd.getahead.dwr.AbstractDWRServlet.doPost(AbstractDWRServlet.java:162) uk.ltd.getahead.dwr.AbstractDWRServlet.doGet(AbstractDWRServlet.java:149) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
这个原因可能是 你的Web.xml中定义DWRSeverlet的时候 出现了重复或者没定义
我检查了Web.xml
中间多出了如下配置,去掉后就可以正常使用
<servlet>
<servlet-name>mydwr</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>scriptCompressed</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mydwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>