ModeAndView 跳转时404

package handlers;

import Model.User;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//正确的包
import org.springframework.web.servlet.*;

@RequestMapping("/HelloWorld")
@Controller
public class HelloWorld {
    private static final String SUCCESS="success";

    @RequestMapping("TestModelAndView")
    public ModelAndView testModelAndView(){
        ModelAndView mv=new ModelAndView(SUCCESS);
        mv.addObject("name","miao");
        return mv;
    }
}

应该导入 org.springframework.web.servlet.ModelAndView;

实际导入 org.springframework.web.portlet.ModelAndView;

你可能感兴趣的:(Spring,MVC)