Getting started with DWR FAQs

Source: Internet
Author: User
Tags csrf attack

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.