Getting “WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI …” when trying to setup spring servlet

后端 未结 3 471
萌比男神i
萌比男神i 2021-01-25 07:56

I am trying to setup a Spring MVC project. I have added a dispatcher servlet, a jsp and setup the web.xml file. But I keep getting

WARN org.springframew

3条回答
  •  生来不讨喜
    2021-01-25 08:30

    I got that error when i migrated/updated from Spring framework 3.X to 4.X and using json (through Jackson2) as returned object and got the error above.

    To solve that you should add

    
        
            
                
                    
                
            
        
    
    
    
        
            
               
           
        
    
    
    
        
    
    

    To XXX-servlet.xml file

    And on the code you should use MappingJackson2JsonView as return value for example :

    @RequestMapping("/user")
    MappingJackson2JsonView user() {
    MappingJackson2JsonView view = new MappingJackson2JsonView();
    view.setExtractValueFromSingleKeyModel(true);
    view.addStaticAttribute("user", new User("Sébastien", "Deleuze"));
    view.setPrefixJson(true);
    return view;
    }
    

    for more examples look here: http://www.programcreek.com/java-api-examples/index.php?api=org.springframework.web.servlet.view.json.MappingJackson2JsonView

提交回复
热议问题