Spring 3.2 content negotiation class cast exception

后端 未结 4 1204
青春惊慌失措
青春惊慌失措 2021-02-04 21:21

We develop a standard Java web application using Spring MVC, and have recently tried to upgrade from 3.0.6 to 3.2.0. Nearly of all our servlet responses are JSP or Json views, b

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 22:07

    Well, the error you posted is basically saying that Spring doesn't have a way to convert the string you provided, for example "application/pdf", to the MediaType objects. I am guessing the ContentNegotiatingViewResolver changed it's mediaTypes map to be a Map to a Map. You could try something like this:

    
    
    
      
        
          
            
          
        
      
      
        
          
            
          
        
      
      
        
          
            
          
        
      
    
    
    

    Note: I did this from memory, so I may have typo'd this. Basically, you need the entry values to be MediaTypes, not strings.

提交回复
热议问题