I want to set each user for my profile link. This way:
@RequestMapping (value = "/ {userlogin}", method = RequestMethod.GET) public string page (@PathVariable ("userlogin") string Userlogin, modelMap model) {System.out.println (userlogin); Return "user"; } But static pages also get this expression .. ..by this way:
@RequestMapping (value = "/ hello "Method = RequestMethod.GET) Public string Hello () {System.out.println (" Hello Mapping "); Return "Hello"; } This happens when I request a "Hello" request which tells the two controllers.
I would like to do this, user control calls only if other methods are not called.
console, when I call localhost: 8080/123:
123 The console, when I localhost: 8080 / hello:
Hello Mapping or
I only want to get
Hello Mapping when Call Localhost: 8080 / Hello
Who knows how it can be implemented?
Spring MVC can use the URI template pattern with regular expressions.
- There are only digits in
user login - Required other URLs are required at least one non-digit Character
You can use it in your @RequestMapping :
@RequestMapping (value = "/ {userlogin: \\ d +} ", Method = RequestMethod.GET) Public String Page (@PathVariable (" userlogin ") string user login, modelmap model) {// ...} The separation URL between userlogin and the other is different than what I imagined, come to optimize it May be hone.
Comments
Post a Comment