Springmvc入门程序及Springmvc执行流程

1.创建一个web工程
2.导入jar
spring-jar
3.配置web.xml

springmvc
org.springframework.web.servlet.DispatcherServlet class>

contextConfigLocation
classpath:springmvc.xml



springmvc
*.do

4配置springmvc.xml







class="org.springframework.web.servlet.view.InternalResourceViewResolver">



5.自定义Controller
public class UserController implements Controller{

@Override
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView mv=new ModelAndView();
mv.addObject("hello", "helloworld");
//设置逻辑视图
mv.setViewName("index");
return mv;
}
}
6定义视图页面
根据视图解析路径:WEB-INF/jsps/index.jsp

你可能感兴趣的:(spring框架,springMVC)