SpringMVC3,使用RequestMappint的Param參數,實現一個url綁定多個方法

來源:互聯網
上載者:User

標籤:web   springmvc   requestmapping   param   

SpringMVC中,預設不能把多個相同的url綁定到同一個方法。如果需要綁定,需要增加param參數,而且值要不同。

  我自己沒有這個需求,或者就是有需求,我也想到的是使用不同的url。

  項目中有少部分這樣的需求,於是就寫個demo。

 @RequestMapping(value="/test",params="method=method1")
public void method1(){
 System.out.println("method1");
}

@RequestMapping(value="/test",params="method=method2")
public void method2(){
 System.out.println("method2");
}

@RequestMapping(value="/test")
public void method3(){
 System.out.println("method3");


 網上也有類似的文章,可以說有一大把,有興趣的去瞭解和實踐下。

 http://huangyunbin.iteye.com/blog/1893471
 
 這裡面存在一個道理:如果你先瞭解一個東西,需要用到的時候,就很容易聯想到。比如某款軟體、某個開源庫、某個不常見的用法。
要不然,你還真難知道存在這麼一項新事物。
 如果你已經掌握的資訊能夠滿足你的需求,並且你適應它了,可能就有懶惰心理了,不想再去學習新知識了。

SpringMVC3,使用RequestMappint的Param參數,實現一個url綁定多個方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.