springMVC給我們提供Controller控制器,用來實現我們的邏輯處理,在Controller接口中定義的方法也是比較簡單的,以下:
Controller接口及實現類:
Controller有多個實現類,這些類就不做過量解釋了,由于我們如果處理自己的業務還是需要重寫他的handleRequest方法的。
Controller接口以下:
public interface Controller { //履行要求處理操作,返回ModelAndView對象 ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception; }
public class ProductImplementController implements Controller { @Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView modelAndView = new ModelAndView("jsp/ProductForm"); return modelAndView; } }
springMVC的容器配置文件中注入這個Controller
<bean name="/input.action" class="com.tianjunwei.controller.ProductImplementController"></bean>這樣終究訪問這個Controller時會跳到jsp/ProductForm的頁面。
上一篇 移動端游戲架構設計
下一篇 射線檢測算法在游戲中應用