Getting started with DWR: ReprintedArticle: Http://blog.csdn.net/stubbornpotatoes/article/details/8744551 The previous blog introduced the demo of DWR. From the demo, we can basically learn how to use DWR. In fact, it is very convenient and simple to use DWR.
When testing the previous blog, just a few lines Code The following problems occur:
Access to debug pages is denied. Solution:
When configuring DWR in Web. XML, You need to configure the debug parameter. The debug parameter is true, as shown below:
<Servlet> <servlet-Name> DWR </servlet-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-mapping> <servlet-Name> DWR </servlet-Name> <URL-pattern>/DWR/* </url-pattern> </ servlet-mapping>
When running a JSP test:
DWR: A request has been denied as a potential csrf attack. Solution: Add initialization parameters when configuring DWR in Web. xml:
<Init-param> <param-Name> crossdomainsessionsecurity </param-Name> <param-value> false </param-value> </init-param>
Note: To ensure that the JS file introduced by JSP is correct, run:
Http: // localhost: 8088/project name/web. the name configured in XML. For example, in the preceding XML, I configure DWR,/DWR/*. In this form of access, the DWR method is used:
Http: // localhost: 8088/testdwr/DWR/ You can view the JS file path.
In another issue, do not use the overload method in the method declared in DWR. js cannot distinguish the overload. For example, the method in the class is as follows: Public String sayhello (string name ); Public String sayhello (); Even if sayhello is called on the JSP page to pass in the parameter, the backend calls the second method without any parameter. If you are interested, you can test it and trace and debug it through Js.