Results 1 to 2 of 2

Thread: Problems with RequestMapping

  1. #1
    Join Date
    Feb 2012
    Posts
    2

    Default Problems with RequestMapping

    Dear friends,
    I'm new of the Spring and i'm developing the my first application with MVC.

    I have two controllers, homeController wich contains two methods

    Code:
    @Controller
    @RequestMapping("/")
    	public String showHomePage(Map<String,Object> model){}
    
    @RequestMapping(value="/categories/{nameCategoria}", method=RequestMethod.GET){ return "homePage"}
    public String showCategoriesPage(){return "CategoryPage"}
    and the RegistrationController
    Code:
    @Controller
    @RequestMapping("/registration")
    public class RegistrationController{
    
    @RequestMapping(method=RequestMethod.GET , params="newUser")
    	public  String createNewUser(Model model){ return RegistrationPage }
    
    }
    In the my HomePage i have a two links

    Code:
    <div align="justify">
    <a href="registration?newUser" style="color: blue;">registration</a>  
    <a href="/categories/nameCategoria" >	categories</a>
    
    </div>
    if i click first on link categories I will return /categories/nameCategoria url Up to here everything is ok, but if after i click on registration link i will return /categories/registration?newUser but it's a bad url for the my RegistrationController,

    while if i click first on registration link, i will return /registration?newUser url which is a sound url for the my RegistrationController

    How can i resolve this problem?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I suggest you take a look at your url. Your registration url should be prefixed with / which means from the root if you leave it out it means relative to the current url.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •