url-routing

How to have URLs without a suffix (e.g .action) in Struts 2?

半世苍凉 提交于 2019-12-03 17:29:12
Here's the thing, I need to not only serve java, but also some javascript files, with my .war. So e,g. if someone goes to the URL: example.com/js/foo.jar Then I need that to be properly served as a javascript file. At the same time, if someone goes to: example.com/bar I need that to be served by Struts2 as a possible controller. The methods I've found online of removing the suffix from the url, would cause both URls to be served by struts 2 (and hence give an error for the first foo.js file even though it exists). Is there a way (such as an interceptor) which will first check if the given .js

How to accept sorting and pagination parameters in all REST URIs using Slim?

北城余情 提交于 2019-12-03 17:13:50
I am using the Slim PHP framework to create a RESTful API for my app. I would like all URLs to be able to accept parameters for sorting and pagination. Can someone tell me the best way to do this? Also, can someone provide me with some proper REST URIs to this? (i.e. http://domain.com/api/category/fruit/?sort=DESC&results=25&page=2 ) <?php require 'Slim/Slim.php'; $sort = "ASC"; $results = 10; $page = 1; $app = new Slim(); $app->get('/wines', function () use ($app) { $sort = $app->request()->params('sort'); $results = $app->request()->params('results'); $page = $app->request()->params('page');

Routing an Angular 2 app with Web API

只愿长相守 提交于 2019-12-03 16:36:53
I have an Angular 2 application created with Angular CLI. This has to call a .NET 4.6 Web API. The route setup of this is driving me nuts. For Angular, the default folder for output is /dist . Angular CLI does all the minification and tree-shaking you can dream of and then outputs both its JavaScript files and index.html to that folder. So if I run index.html , those files are retrieved from the same folder. Everything works well, because index.html contains a tag like this one: <base href="/"> The Web API project has the expected structure, with the Angular app a parasite in its root. So it

AngularJS / Ionic routing using $stateProvider - controller is not reloading the second time a state is called

穿精又带淫゛_ 提交于 2019-12-03 16:36:16
Original Question I'm developing a mobile app using the Ionic Framework and AngularJS and I am having issues with controllers not reloading once they have been initialised. One of the state transitions (from 'app.postbox-details' to 'app.audit-questions' ) should pass a parameter to the 'app.audit-questions' controller but this controller does not update itself with the new parameter because it isn't reloading. Code Example app.js file - config angular.module('sf-maintenance', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova']) .config(function ($stateProvider,

yii: internationalization (i18n) and dynamic url manager

谁说我不能喝 提交于 2019-12-03 16:20:56
I would like to know a better way to implement "internationalization (i18n)" and "dynamic URL management" in Yii framework. A (difficult to maintain) temporary solution: // protected/config/main.php 'language' => 'es', ... 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName' => false, 'rules'=>array( // pages 'es/turismo/<slug:>' => array('visit/page', 'defaultParams' => array('lang' => 'es'), 'urlSuffix' => '.html'), 'it/visita/<slug:>' => array('visit/page', 'defaultParams' => array('lang' => 'it'), 'urlSuffix' => '.html'), 'en/travel/<slug:>' => array('visit/page', 'defaultParams' =>

How to EnableCaseInsensitive, EnableEnumPrefixFree and EnableUnqualifiedNameCall in OData v6.0.0

不想你离开。 提交于 2019-12-03 16:10:31
I recently updated OData from (v5.9.1) to the latest stable version (v6.0.0) and in the former one I used to configure my environment like this: //Allows calling the Url like {entityAction}/{id} config.SetUrlConventions(ODataUrlConventions.KeyAsSegment); //Allows urls to be case insensitive config.EnableCaseInsensitive(true); // Remove the necessity of having to specify the namespace of enums. config.EnableEnumPrefixFree(true); //This allows call a function without using the full namespace. config.EnableUnqualifiedNameCall(true); config.MapODataServiceRoute("odata", "api/rest", edmModel, new

RedirectToAction() with tab-id

巧了我就是萌 提交于 2019-12-03 15:18:24
I have a web application in ASP.NET MVC and in there i have a jqueryUI tab with forms in. And when i submit i want to return to the open tab. With me RedirectToAction() i create the url www.foo.com/CV/edit/9 But i want to be able to generate www.foo.com/CV/edit/9#tab-2 I tried with RedirectToAction("edit/"+id+"#tab-2"), but that generates: www.foo.com/CV/edit/9%23tab-2 any1 knows the answer? Create the URL, then append #tab-2 to it. Return a RedirectResult to redirect to the created URL: return new RedirectResult(Url.Action("edit", new { id }) + "#tab-2"); You can't redirect to a hashed URL

MVC 2.0 dynamic routing for category names in an e-store

北城以北 提交于 2019-12-03 14:13:37
I'm currently working on an e-store using ASP.NET MVC 2.0. I already got most of it up and running, but the part that's been bothering me is routing. I want this: http://mystore.somewhere/my-category-1/ So far I've been able to solve it by using: routes.MapRoute( "Category", "{alias}/{pageNumber}", new { controller = "Categories", action = "Browse", pageNumber = 1 }); But this catches way too much than just what I'd like. After reading through some questions and answers around this site, I found a particulary interesting solution that would require me to programatically register a route for

Routes with trailing slashes in Pyramid

别说谁变了你拦得住时间么 提交于 2019-12-03 13:54:30
Let's say I have a route '/foo/bar/baz'. I would also like to have another view corresponding to '/foo' or '/foo/'. But I don't want to systematically append trailing slashes for other routes, only for /foo and a few others (/buz but not /biz) From what I saw I cannot simply define two routes with the same route_name. I currently do this: config.add_route('foo', '/foo') config.add_route('foo_slash', '/foo/') config.add_view(lambda _,__: HTTPFound('/foo'), route_name='foo_slash') Is there something more elegant in Pyramid to do this ? Found this solution when I was looking for the same thing

Racket URL dispatch

喜欢而已 提交于 2019-12-03 13:19:41
问题 I'm trying to hook up URL dispatch with Racket (formerly PLT Scheme). I've taken a look at the tutorial and the server documentation. I can't figure out how to route requests to the same servlets. Specific example: #lang scheme (require web-server/servlet) (require web-server/dispatch) (provide/contract (start (request? . -> . response/c))) (define (start request) (blog-dispatch request)) (define-values (blog-dispatch blog-url) (dispatch-rules (("") list-posts) (("posts" (string-arg)) review