controller配置彙總

2021-07-11 15:29:15 字數 756 閱讀 6238

1.通過url對應bean

以上配置訪問/hello.do就會尋找id為/hello.do的bean,此類方式僅使用小型應用系統

2.為url分配bean

使用乙個統一配置集合,對各個url對應的controller做關係對映

hellocontroller

此類配置還可以使用萬用字元,訪問/hello.do時,spring會把請求分配給hellocontroller進行處理。

3.url匹配bean

如果定義的conroller名稱規範,也可以使用如下配置

4註解

在controller中新增註解:

第二講 Controller配置彙總

一 通過url對應bean name hello.do class com.liujie.controller.hellocontroller 以上配置,訪問 hello.do就會尋找name id為 hello.do的bean,此類方式只適應於小型的應用系統。此類配置還可以使用 萬用字元。二 為u...

使用 Controller註解為什麼要配置

自己看了官方文件,也到網上查了下,目前理解如下 mvc annotation driven context component scan base package com context component scan web.xml servlet servlet name mvc servlet ...

SpringMvc的Controller的返回值

controller方法返回值 指定返回到哪個頁面,指定返回到頁面的資料 1 modelandview modelandview.addobject itemlist list 指定返回頁面的資料 modelandview.setviewname itemlist 指定返回的頁面 2 string ...