routing

Routing in Symfony2: optional parameter en four urls for one route

别等时光非礼了梦想. 提交于 2019-12-19 03:21:19
问题 In my Symfony2 application I would like to make four urls possible with one route: a-lot-of-other-stuff/report/-20 (negative number) a-lot-of-other-stuff/report/40 (positive number) a-lot-of-other-stuff/report/ (no number) a-lot-of-other-stuff/report (no number and no / ) My route currently looks like this: report: pattern: /report/{days} defaults: { _controller: "AppReportBundle:Report:dayReport", days = null } The action is defined as: public function dayReportAction($days = null) { // my

Routing, an unlimited number of parameters

Deadly 提交于 2019-12-19 02:55:26
问题 For example, link: /shop/phones/brend/apple/display/retina/color/red where: phones - category alias brend - name of attribute; apple - attribute value display - name of attribute; retina - attribute value color - name of attribute; red - attribute value Attributes can be any number. Order may also be different. The beginning of the route is clear: /shop/{category} And what to do next is unclear. In symfony 1, a set at the end star ("/shop/:category/*") and all that was not clearly marked, and

Routing, an unlimited number of parameters

空扰寡人 提交于 2019-12-19 02:55:05
问题 For example, link: /shop/phones/brend/apple/display/retina/color/red where: phones - category alias brend - name of attribute; apple - attribute value display - name of attribute; retina - attribute value color - name of attribute; red - attribute value Attributes can be any number. Order may also be different. The beginning of the route is clear: /shop/{category} And what to do next is unclear. In symfony 1, a set at the end star ("/shop/:category/*") and all that was not clearly marked, and

Angular 2 Routing based on query params

心不动则不痛 提交于 2019-12-19 02:32:29
问题 Is it possible in Angular 2 to define routing based on query parameters? I'd like to have the following behaviour: If the user enteres the url http:<server-path>/search I'd like to route to a StartPage component. If the user enteres the url http:<server-path>/search?query=sometext I'd like to route to ResultList component. I know that it's possible to use path parameters for routing but this is not what I like to do. I want to use query parameters if possible. I know how to trigger navigation

Java finding network interface for default gateway

孤者浪人 提交于 2019-12-19 02:06:10
问题 In Java, I'd like to find the java.net.NetworkInterface corresponding with the interface used reach the default gateway. The names of the interfaces, etc, are not know ahead of time. In other-words, if the following was my routing table, I would want the interface corresponding with "bond0": $ netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 10.10.10.0 * 255.255.255.0 U 0 0 0 bond0 10.10.11.0 * 255.255.255.0 U 0 0 0 eth2 10.10.11.0 * 255.255.255.0 U 0

CodeIgniter optional parameter

▼魔方 西西 提交于 2019-12-18 19:41:13
问题 I'm trying to use routing in CI to create a signup form signup is re-routed to user/signup But my signup function can contain a paramater: function signup($type = 1) How can I make this optional via routing? I tried $route['signup/?(:num)'] = 'user/signup/$1'; , but when going to /signup I'm getting a 404, only /signup/1/ works. 回答1: The clearest way to express this would probably be to declare both routes: $route['signup'] = "user/signup"; $route['signup/(:num)'] = "user/signup/$1"; 回答2: For

Correct 404 message for a missing ASP.Net MVC controller

限于喜欢 提交于 2019-12-18 18:27:49
问题 I have an MVC 2 application that should always give a 'nice' 404 page. However currently I get a low level .Net one: "Server Error in '/sitename' Application..." I have a base controller that has a NotFound action that will render the nice 404 page. Missing actions are handled: protected override void HandleUnknownAction(string actionName) { this.NotFound(actionName).ExecuteResult(this.ControllerContext); } So a visit to {site}/ValidController/NotAnAction gets routed correctly. However a

How can I fix the missing implicit value for parameter ta: TildeArrow in a test spec

放肆的年华 提交于 2019-12-18 14:15:41
问题 I'm working on a simple test spec using spray and I can't get it to compile correctly, don't know if I'm doing anything wrong. My version of scala is 2.9.3 and spray 1.0.1 (Updating either of them is not a suitable option). Here's my test spec's code: import org.specs2.mutable.Specification import spray.testkit.Specs2RouteTest import spray.http._ import akka.util.Duration import java.util.concurrent.TimeUnit import service.MyProxy abstract class MyTestSpec extends Specification with

Routing to the actions with same names but different parameters

点点圈 提交于 2019-12-18 14:00:40
问题 I have this set of routes: routes.MapRoute( "IssueType", "issue/{type}", new { controller = "Issue", action = "Index" } ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Here is the controller class: public class IssueController : Controller { public ActionResult Index() { // todo: redirect to concrete type return View(); } public ActionResult

Redirect to controller (but with a different master) using a catchall wildcard

大城市里の小女人 提交于 2019-12-18 13:38:30
问题 I have a problem whereby I want to display a view differently (a different master page), depending on where it came from, but don't know where to start... I have several routes which catch various different types of urls that contain different structures. In the code snippet below, I have a product route, and then I have a partner site route which could also go to a product page, but let's say that this partner is Pepsi, and they want their branding on the master page, rather than our own