Could not read document: Unrecognized field "***" 解决方案!

org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.handleHttpMessageNotReadable Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Unrecognized field "age1" (class com.byd.shop.entity.User), not marked as ignorable (4 known properties: "id", "sex", "age", "name"])

1、原因分析

实体类中不存在post提交的age1,从而程序抛出异常。

2、在实体类添加  @JsonIgnoreProperties(ignoreUnknown = true)

3、springweb.xml添加


    
        
            
                
                    
                    
                        
                            
                        
                    
                    
                    
                        NON_NULL
                        
                        
                        
                        
                        
                        
                    
                
            
        
    

4、重启即可。

 

 

 

 

 

 

 

你可能感兴趣的:(spring,java)