org.directwebremoting.util.CommonsLoggingOutput error
严重: A request has been denied as a potential CSRF attack.
在参照dwr的官方网站时,如果在后台出现如下的提示信息:A request has been denied as a potential CSRF attack
则,需要在web.xml中的如下配置修改一下
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-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>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-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>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
此处servlet-class值为uk.ltd.getahead.dwr.DWRServlet (如果dwr版本是1.0版本的,则必须用这个class)
也可以是org.directwebremoting.servlet.DwrServlet
如果确定java类的方法被调用了,但是页面还是出现了如下的报错: 例外被抛出且未被接住
此时,就不要忧郁了,赶紧换dwr.jar包,
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>