Monday, February 21, 2011

Looking for a java web framework that support django styled url handling

I'm looking for a java web framework that will allow you to configure dynamic urls where information is being passed to the controller.

For example

/{clientName}/login

would call the same controller regardless of the clientName and pass that clientName as an accessible value or an object in it's own right.

From stackoverflow
  • You can use Django on Jython.

    Santa : I think the OP meant in the Java language.
  • Spring MVC @Controllers allows that kind of request mappings in a very simple way. See "15.3.2 Mapping requests with @RequestMapping" for details.

    @Controller
    public class AppointmentsController {
    
        @RequestMapping(value="/appointments/{day}", method = RequestMethod.GET)
        public Map<String, Appointment> getForDay(@PathVariable int day) {
            ...
        }
    
        @RequestMapping(value="/appointments/new")
        public AppointmentForm getNewForm() {
            ...
        }
    }
    

    It is available since Spring 2.5.

  • SpringMVC can be configured for this kind of URL routing since version 2.5. You have tu use annotations as described in http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping

    Good luck !

  • You can use UrlRewriteFilter to rewrite the URLs (for the sake of them being "pretty") for any java web framework.

    In addition, there is PrettyFaces for JSF.

0 comments:

Post a Comment