Spring MVC 跳转失败,但配置正确填坑

1:正确写法

@RequestMapping("{type_key}.html")
public String geren(Model model, @PathVariable String type_key) {
List<EmployeeModel> emplist = employeeService.selectOnjobEmployee();
model.addAttribute("type_key", type_key);
model.addAttribute("emplist", emplist);
return "/front/e/aaa";
}

2:正确写法

@RequestMapping("/ama")
public ModelAndView lists(ModelAndView mv) {//import org.springframework.web.servlet.ModelAndView;


mv.setViewName("/back/b");
return mv;
}

import org.springframework.web.portlet.ModelAndView;跳转无效

引包时候一定注意了是servlet不是portlet

原文地址:https://www.cnblogs.com/coderdxj/p/6675429.html