在我的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。如果有任何其他方式可以获得实际请求,请告诉我。
记录wildfly
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
答案 0 :(得分:0)
我能够通过另一种解决方法获得forwardURI。虽然,不是获得forwardURI的理想方式,但它对我有用。
forwardURI = request?.attributes.get("javax.servlet.error.request_uri")