About the alter solution that pops up when dwr eliminates server output errors

Source: Internet
Author: User

Environment: dwr3 + jsp

During development, I really don't want dwr to bring up alter. I only need to print the error log. The client does not need alert to generate an error or a server error has occurred. such a prompt does not require alert to output stack information, and the customer does not need to read it. What should I do?

After analysis, engine. js contains the default error handle of dwr, defaultErrorHandler. If you do not define errorhandler, defaultErrorHandler will be assigned to errorhandler. Then we can write a js file to overwrite errorhandle.

The js content is as follows:

Dwr. engine. _ errorHandler = function (message, ex) {dwr. engine. _ debug ("Error:" + ex. name + "," + ex. message, true );};

There is only one sentence above. When this js is introduced to the page to be added, an error occurs on the dwr service end, which only prints the log and does not alter it.




UseAjaxOfDwrFramework pop-upErrorDialog Box

In the SSH framework, the error dialog box is displayed using the ajax dwr framework, which is prone to this situation. This is a unified error prompt, but this prompt is not friendly enough and does not know the details of the error. You can add the following code in the <allow> node of the dwr. xml configuration file.

View source

Print?

1

<ALLOW>

2

<CONVERTconverter = "bean" match = "java. lang. StackTraceElement"/>


3

<CONVERTconverter = "exception" match = "java. lang. Exception"/>

4

</ALLOW>


In this case, the error details can be printed. The "a server error has occured" prompt box is usually displayed. This is generally because when javascript calls the java method, at this time, the business logic layer biz/service is not generated by spring. Therefore, the business logic layer cannot be injected into the data access layer (General dao). There are two solutions:

1. You can create a new spring configuration file applicationContext, or write your own data access implementation in the java method to be accessed by javascript.

2. Changing "bean" to "spring" indicates that the bean is not created by itself, but created by spring.

View source

Print?

1

<ALLOW>

2

<CONVERTconverter = "spring" match = "java. lang. StackTraceElement"/>


3

<CONVERTconverter = "exception" match = "java. lang. Exception"/>

4

</ALLOW>


Related Article

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.