一、向请求域共享数据
1.ModelAndView
public ModelAndView getModeAndViewTest(){
ModelAndView mav=new ModelAndView();
mav.addObject("tean","haiahiai");
mav.setViewName("success");
}
2.Model
public String getModelTest(Model model){
model.addAttribute("tean","haiha");
return "success";
}
3.ModelMap
public String getModelTest(ModelMap modelMap){
modelMap.addAttribute("tean","haiha");
return "success";
}
二、SpringMVC工程放行非SpringMVC的请求
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("**/包名/**").addResourceLocations("/包名/");
}
}