Spring 3.2 content negotiation class cast exception

后端 未结 4 1287
青春惊慌失措
青春惊慌失措 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条回答
  •  青春惊慌失措
    2021-02-04 21:58

    I think you can achieve the same thing more easily using the ContentNegotiationManagerFactoryBean. By default it checks the URL path extension first, then a format property in the URL (such as ..../accounts?format=pdf) and then the standard HTTP Accept header property. The use of the format parameter is off by default.

    
        
    
        
            
                
                
                
           
        
    
    
    
            
    
    

    If you use the JavaBeans Activation Framework, JAF, you shouldn't need the mediaTypes section. Just put activation.jar on the classpath.

    Did you try this and did you also get class-cast exceptions?

提交回复
热议问题