Announcement Announcement Module
Collapse
No announcement yet.
@RequestMapping values but dynamics Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @RequestMapping values but dynamics

    Hi,

    After looking for the different default HandlerMapping (bean/annotation/simple) and their options for spring, i am style confuse about it, because none of them seams to treat my case.But in same time my case is so classic that i am sure i misted something.
    I want to treat a dynamic url mapping. In all the example i found for the mapping you are suppose to know the structure of your URL like :
    /*/{$toto}
    /pet/{$petid}

    Etc ...

    I need to know all the path of the url to find out the correct view. I don't want to pass any parameter in my request because the path of the url define the view to call.
    But the length of this url is dynamic.
    It's can be : /menu1/menu2/menu3/car.htm but i can't configure manually in the xml file all the combination of this menu ...
    Without spring i just extract from the request object the full URL and i parse it to find the correct view.
    But with spring i am stuck. I don't believe Spring don't treat this case.

    Or if it's not possible i was imaginaning to put a filter and set some attribute to my request related to the path of the URL. But apparently the controller can refind the session attribute and only the session attribute .. i dont know why :-(

    Thanks for your help
    Last edited by Drazhar; Jul 8th, 2011, 12:17 PM.

  • #2
    I am confused with your case but

    the URL is used to map or get the best match with a @Controller class and then select a specific method which has the @RequestMapping and has a value very closely related with the URL pattern sent it, it is not related with the view name, your method should return a view name like String, to be resolved with Spring MVC views resolution.

    Expand more your situation, I am confused

    Comment


    • #3
      Thanks for your anwser

      Forget the view. My problem is to refind in my method of controler by anyway the content of the full original path. I just want to do a basic url rewrite where the url path is dynamic.

      If am confuse it's also because maybe i don't know enougth the subject but if i decide to have 4 controller.
      1 controller for /section1/
      1 controller for /section2/
      etc..

      Ok. I want to get the last element, the page name. But for section2 , he path is dynamic, i don't know it will be /menu1/submenu2/ etc...
      But i still want to get the name of the last element like with @RequestMapping /{$param}.

      After i still looking on internet and apparently a solution for my problem consist to url urlrewrite_mod de Apache and in addition of redirect all the flux to my spring dispatcher i could pass the full url in a get param and in this case i find my full url in the param of my controller because i will always receive a template like /section1/ with his get param witch contain the url.

      Comment


      • #4
        Problem solved , nothing related to Spring.
        With mod_rewrite of Apache you can easily pass in get parameter the original url. So i will find my information in my parameter of my controller.

        Thanks

        Comment

        Working...
        X