开发者

grails and debugging UrlMappings

In grails, how can I add some code to the UrlMappings.groovy (ex: println) so that I can figure out what the request URI is and which mapping is getting hit (if any)?

Background:

In this situation, there are two servers which serve different things based on file extension. So, the two servers need to always see file extensions for error processing to continue. Otherwise, the servers get confused and 1 serves up a 404 page instead of our 500 page.

The bigger picture involves开发者_如何转开发 taking a 500 response due to something like a NullPointerException and tracing it through the code to see what is happening.

I added code like the following which is at http://jetlet.blogspot.com/2010/08/grails-exception-handling-with-response.html :

"500" (controller: "error", action: "internalError")

In testing this, I am throwing a NullPointerException (NPE) on purpose. The 500 handling is called and 500 page is served up when entering in the URL into the browser's address bar. However, when posting a form to the server and having the processing code blow up on purpose with a NPE, the "500" handling code does not get called. The URL in the form's action seems to end with an extension. So, not sure why the difference in behavior between the GET (browser URL) and POST (form submission).

Thanks for insights and thoughts on tracking this down !


In your Config.groovy you can modify your log4j settings for url mapping events by adding

all 'org.codehaus.groovy.grails.web.mapping'

to your existing log4j settings. all is the most verbose setting so it can be tuned back if that starts giving you too much. You can find more information in the official grails documentation here : http://grails.org/doc/latest/guide/3.%20Configuration.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜