需求:http://localhost:80/order/service?method=getTradeInfo
http://localhost:80/order/service?method=createTrade像這種需要通過method來決定映射到哪個controller的哪個方法,應該如何實現?現在只知道spring mvc會通過/order/service和請求方法(get,post)來決定請求應該由哪個controller的哪個方法去處理。
4 回答

嚕嚕噠
TA貢獻1784條經驗 獲得超7個贊
http://localhost:8080/order/service/{method}
進入的方法參數為(@PathVariable String method),
可以判斷method調用不同的service處理

拉風的咖菲貓
TA貢獻1995條經驗 獲得超2個贊
controller的一個方法接,然后解析輸入參數method的值,走不同的邏輯分支
@RequestMapping("/order/service")
public ModelAndView process(String method){
// 根據method的值,走不同邏輯分支
}
添加回答
舉報
0/150
提交
取消