Spring 3.2 content negotiation class cast exception

后端 未结 4 1205
青春惊慌失措
青春惊慌失措 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 22:11

    With spring 3.2 it is better resolved using ContentNegotiationManager. It is working for me. You could use the static field like org.springframework.http.MediaType.APPLICATION_JSON_VALUE to mention the mediatype. check the following code:

    
            
                
                    
                        
                            
                                
                                    
                                        
                                    
                                    
                                        
                                    
                                
                            
                        
                    
                
            
    
            
                
                   
                
            
    
        
    

    For this you have to use util schema in your dispatcher-servlet.xml file, i.e. xmlns:util="http://www.springframework.org/schema/util" and schema location http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd

提交回复
热议问题