1.在spring配置文件中 开启注解支持
<context:component-scan base-package="com.example.controller"/>
<mvc:default-servlet-handler/>
<mvc:annotation-driven/>
2.编写controller
@Controller
public class MyController {
@RequestMapping("/h")
public String sayHello(Model model){
model.addAttribute("msg","hello springmvc");
return "test";
}
}
3.其他配置参考上一篇博客