我是spring mvc3開發的新手,並且面臨一個小問題(我沒有面對ASP.Net MVC3)。我想知道爲控制器定義默認(或着陸)URL的過程。定義控制器彈簧的默認網址mvc3
我有一個帳戶控制器,我做所有帳戶管理相關的東西。所以我所有的url都映射到這個控制器。我想知道如何將我的「/ accounts」url請求映射到openAccountsDashboard
方法?
碼 -
.... imports...
@Controller
@RequestMapping(value = "/accounts/*")
public class AccountController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView openAccountsDashboard(HttpServletRequest request) {
.....
return new ModelAndView("accounts/landing");
}
@RequestMapping(value = "/change-password", method = RequestMethod.GET)
public ModelAndView openPasswordChangePage(HttpServletRequest request) {
.....
return new ModelAndView("accounts/passwordChange");
}
... other actions...
}
任何幫助將是巨大的!
感謝
當您刪除openAccountsDashboard的attr值時會發生什麼情況? – 2012-08-17 05:43:12
它只是當我使用url - '/ accounts /'而不是'/ accounts'(給404) – saarthak 2012-08-17 06:14:55
時,爲什麼不刪除/ *,只是在類級別使用/ accounts,並在方法中添加自定義路徑級別/更改密碼 – 2012-08-17 07:23:51