国产一区二区精品久久_蜜桃狠狠狠狠狠狠狠狠狠_午夜视频精品_激情都市一区二区

當前位置:首頁 > 網站舊欄目 > 學習園地 > 設計軟件教程 > 每天一劑Rails良藥之Make your URLs Meaningful(and pretty)

每天一劑Rails良藥之Make your URLs Meaningful(and pretty)
2010-01-14 07:06:14  作者:  來源:
這篇內容沒什么價值,《Agile Rails》里的Routing Request一節講述的比較詳細了
Java代碼 復制代碼
  1. ActionController::Routing::Routes.draw do |map|   
  2.   map.connect ':controller/service.wsdl', :action => 'wsd'  
  3.   map.connect ':controller/:action/:id'  
  4.   map.connect ':user', :controller=> 'recipes',   
  5.                       :action => 'list',   
  6.                       :filter => 'user'  

其實上面的代碼是調用map.connect()方法:
Java代碼 復制代碼
  1. map.connect(String path, Hash options)  

再就是Named Routes:
Java代碼 復制代碼
  1. map.popular 'popular/:tag', :controller => 'recipes',   
  2.                             :action => 'list',   
  3.                             :tag => '',   
  4.                             :filter => 'popular'  

這會生成popular_url()和popular_path()方法,前者是絕對路徑的鏈接,后者是相對路徑的鏈接
安徽新華電腦學校專業職業規劃師為你提供更多幫助【在線咨詢