This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Spring and the fly likes Missing part of string from Spring PathVariable mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Missing part of string from Spring PathVariable mapping" Watch "Missing part of string from Spring PathVariable mapping" New topic
Author

Missing part of string from Spring PathVariable mapping

sam White
Ranch Hand

Joined: Feb 18, 2011
Posts: 208
Hi with spring mvc 3.0.5 and jsp, I use Spring PathVariable to pass an {id} to controller, where {id} is an email address.
After the id has been passed into the controller, the tailing .au of the email address is missing.

Here is the log messages:



In the above log message, I am passing in email address samuel@morfeusflex.com.au as the {id}, but ".au" is missing from its mapping.

here is my jsp file:



controller class:



What is wrong with the spring mapping in my example?

Any suggestion is very appreciated.
Thanks
Sam
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes, there are some characters that end up making it the end of that pathVariable even though there might be more text in it. So you have to break it into more than one pathVariable and then concatenate the Strings adding the character that caused the problem

In your email example that would be the "."

so I recomment

myApp/{firstPart}.{lastPart}

public String someMethod(@PathVariable("firstPart") String first, @PathVariable("secondPart") String second) {

String email = first + "." + second;

}


Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
GeeCON Prague 2014
 
subject: Missing part of string from Spring PathVariable mapping