Spring中MVC模块代码详解-创新互联
SpringMVC的Controller用于处理用户的请求。Controller相当于Struts1里的Action,他们的实现机制、运行原理都类似
创新互联建站是一家专注于网站设计制作、成都做网站与策划设计,濂溪网站建设哪家好?创新互联建站做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:濂溪等地区。濂溪做网站价格咨询:13518219792Controller是个接口,一般直接继承AbstrcatController,并实现handleRequestInternal方法。handleRequestInternal方法相当于Struts1的execute方法
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.AbstractController; public class CatController extends AbstractController{ private ICatService catService; //setter、getter略 protected ModelAndView handleRequestInternal(HttpServletRequestrequest,HttpServletResponse response) throws Exception{ String action =request.getParameter("action"); if("list".equals(action)){ return this.list(request,response); } } protected ModelAndView list(HttpServletRequestrequest,HttpServletResponse response) throws Exception{ ListcatList =catService.listCat(); request.setAttribute("catList", catList); return new ModelAndView("cat/listCat"); } }
当前标题:Spring中MVC模块代码详解-创新互联
转载注明:http://lswzjz.com/article/jjihd.html