Announcement Announcement Module
Collapse
No announcement yet.
Problems with RequestMapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X