File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed 
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 4040import  org .springframework .web .context .support .WebApplicationContextUtils ;
4141import  org .springframework .web .method .annotation .RequestParamMethodArgumentResolver ;
4242import  org .springframework .web .method .support .CompositeUriComponentsContributor ;
43+ import  org .springframework .web .servlet .DispatcherServlet ;
44+ import  org .springframework .web .servlet .support .RequestContextUtils ;
4345import  org .springframework .web .servlet .support .ServletUriComponentsBuilder ;
4446import  org .springframework .web .util .UriComponents ;
4547import  org .springframework .web .util .UriComponentsBuilder ;
@@ -297,10 +299,10 @@ protected static CompositeUriComponentsContributor getConfiguredUriComponentsCon
297299			logger .debug ("Request bound to current thread is not an HttpServletRequest" );
298300			return  null ;
299301		}
300- 		ServletContext   servletContext  = request .getServletContext (); 
301- 		WebApplicationContext   wac  =  WebApplicationContextUtils . getWebApplicationContext ( servletContext );
302+ 		WebApplicationContext   wac  = ( WebApplicationContext )  request .getAttribute ( 
303+ 				 DispatcherServlet . WEB_APPLICATION_CONTEXT_ATTRIBUTE );
302304		if  (wac  == null ) {
303- 			logger .debug ("No WebApplicationContext found: no ContextLoaderListener registered ?" );
305+ 			logger .debug ("No WebApplicationContext found: not in a DispatcherServlet request ?" );
304306			return  null ;
305307		}
306308		try  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments