0

在我的 grails 应用程序中,我有一个“404”的自定义重定向。每当应用程序遇到 404 时,它都会记录 request.forwardURI 并将用户重定向到 404 页面。但是在升级到 wildfly-8.0.0(也尝试过 8.1.0 和 9.0.0-alpha)后,应用程序不会记录实际的 URI(request.forwardURI)。

但是,在请求转储中,我看到了请求的实际 URI。我相信,这可能不是 grails 问题,因为实际请求正在登录 jboss-4 和 jboss-eap-6.2。Wildfly 中的 Request 类是 HttpServletRequestImpl,而在旧版本中是 ApplicationHttpRequest。

我已将战争复制到https://www.dropbox.com/sh/trzzmfp7pp5ut0f/AADBDczE4fx1oJGDUAw8FxAqa?dl=0。请让我知道是否有任何其他方式可以获得实际请求。

野蝇的日志

10:32:18,242 INFO  [stdout] (default task-8) Request Class *** class io.undertow.servlet.spec.HttpServletRequestImpl
10:32:18,242 INFO  [stdout] (default task-8) Request dump-------------------
10:32:18,245 INFO  [stdout] (default task-8) <io.undertow.servlet.spec.HttpServletRequestImpl@6d806f8e exchange=HttpServerExchange{ GET /test1/grails/common/redirectUrl.dispatch} originalServletContext=io.undertow.servlet.spec.ServletContextImpl@4a622bb servletContext=io.undertow.servlet.spec.ServletContextImpl@4a622bb attributes=[javax.servlet.forward.request_uri:/test1/grails-errorhandler, org.springframework.web.servlet.DispatcherServlet.THEME_SOURCE:org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@52728c5: startup date [Thu Sep 18 10:31:55 IST 2014]; parent: Root WebApplicationContext, org.springframework.web.servlet.DispatcherServlet.THEME_RESOLVER:org.springframework.web.servlet.theme.FixedThemeResolver@39ec09de, javax.servlet.forward.context_path:/test1, javax.servlet.error.servlet_name:default, javax.servlet.error.message:Not Found, javax.servlet.forward.servlet_path:/grails-errorhandler, org.codehaus.groovy.grails.GRAILS_APPLICATION_ATTRIBUTES:org.codehaus.groovy.grails.web.servlet.DefaultGrailsApplicationAttributes@377beb87, urlMapping.FILTERED:true, charEncodingFilter.FILTERED:true, org.codehaus.groovy.grails.FLASH_SCOPE:[:], org.codehaus.groovy.grails.CONTROLLER_NAME_ATTRIBUTE:common, org.codehaus.groovy.grails.CONTROLLER:CommonController@28a40886, javax.servlet.error.request_uri:/test1/asdf, hiddenHttpMethod.FILTERED:true, grailsWebRequest.FILTERED:true, javax.servlet.forward.query_string:null, org.springframework.web.servlet.DispatcherServlet.FLASH_MAP_MANAGER:org.springframework.web.servlet.support.SessionFlashMapManager@292baa42, javax.servlet.forward.path_info:null, org.springframework.web.servlet.DispatcherServlet.CONTEXT:org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@52728c5: startup date [Thu Sep 18 10:31:55 IST 2014]; parent: Root WebApplicationContext, javax.servlet.error.status_code:404, org.codehaus.grails.INCLUDED_JS_LIBRARIES:[], org.codehaus.groovy.grails.ACTION_NAME_ATTRIBUTE:redirectUrl, org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.GSP_SITEMESH_PAGE:org.codehaus.groovy.grails.web.sitemesh.GSPSitemeshPage@71b6e82b, org.springframework.web.servlet.DispatcherServlet.OUTPUT_FLASH_MAP:[:], com.opensymphony.sitemesh.APPLIED_ONCE:true, org.hibernate.impl.SessionFactoryImpl@22de1eda.PARTICIPATE:1, org.codehaus.groovy.grails.WEB_REQUEST:ServletWebRequest: uri=/test1/grails/common/redirectUrl.dispatch;client=127.0.0.1, org.springframework.web.servlet.DispatcherServlet.LOCALE_RESOLVER:org.springframework.web.servlet.i18n.SessionLocaleResolver@1f449960] servletInputStream=null reader=null cookies=null parts=null asyncStarted=false asyncContext=null queryParameters=[:[]] parsedFormData=null characterEncoding=UTF-8 readStarted=false sessionCookieSource=null>
10:32:18,246 INFO  [stdout] (default task-8) ---------------------------
10:32:18,247 INFO  [stdout] (default task-8) Request URI *** /test1/grails/common/redirectUrl.dispatch
10:32:18,249 INFO  [stdout] (default task-8) Forward URI *** /test1/grails-errorhandler

旧 jboss 的日志

10:25:37,510 INFO  [stdout] (http-/127.0.0.1:8080-1)  Request Class *** class org.apache.catalina.core.ApplicationHttpRequest
10:25:37,510 INFO  [stdout] (http-/127.0.0.1:8080-1) Request dump-------------------
10:25:37,514 INFO  [stdout] (http-/127.0.0.1:8080-1) <org.apache.catalina.core.ApplicationHttpRequest@4cc7420c context=StandardEngine[jboss.web].StandardHost[default-host].StandardContext[/test1] contextPath=/test1 crossContext=false dispatcherType=1 parameters=[:] parsedParams=true pathInfo=null queryParamString=null queryString=null requestDispatcherPath=/grails-errorhandler requestURI=/test1/grails/common/redirectUrl.dispatch servletPath=/grails/common/redirectUrl.dispatch session=null specialAttributes=[null, null, null, null, null, null, null, null, null, null, null, null, null, null, null] request=org.apache.catalina.core.ApplicationHttpRequest@1ad23c25>
10:25:37,514 INFO  [stdout] (http-/127.0.0.1:8080-1) ------------URI and domainname --------------
10:25:37,515 INFO  [stdout] (http-/127.0.0.1:8080-1) Request URI *** / /test1/grails/common/redirectUrl.dispatch
10:25:37,516 INFO  [stdout] (http-/127.0.0.1:8080-1) Forward URI *** /test1/test
4

1 回答 1

0

我能够通过另一种解决方法获得 forwardURI。虽然,不是获得 forwardURI 的理想方式,但它对我有用。

forwardURI = request?.attributes.get("javax.servlet.error.request_uri")
于 2014-09-18T07:16:25.183 回答