悬赏园豆:50
[已解决问题]
解决于 2008-03-21 09:21
<P>routes.Add(new Route("{action}/{id}", new MvcRouteHandler())<BR>{<BR> Defaults = new RouteValueDictionary(new { controller = "", action = "", id = "" }),<BR> <FONT color=#ff0000>Constraints = new RouteValueDictionary { { "id", @"\d+" } }</FONT><BR>});</P>
<P>这是在Global中定义一个URL规则,相信已经有许多人用过,标红的这句是添加一个id为数字时才匹配的约束,我的问题是 <FONT color=#000000>new RouteValueDictionary { { "id", @"\d+" } } 这句是啥语法 new Class{ {"", ""} }这两对花括号是什么意思,里面的那对是一个匿名类吗?<BR>这是RouteValueDictionary的构造方法:<BR>public RouteValueDictionary();<BR>public RouteValueDictionary(IDictionary<string, object> dictionary);<BR>public RouteValueDictionary(object values);<BR>protected RouteValueDictionary(SerializationInfo info, StreamingContext context);<BR></FONT></P>