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> |