This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 17249
    
    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
 
Don't get me started about those stupid light bulbs.
 
subject: Missing part of string from Spring PathVariable mapping
 
Similar Threads
controller with Spring annotation ?
Strange error with validation - Invalid property
Spring : DefaultAnnotationHandlerMapping not mapping URL using annotation
Spring MVC+iBATIS simple Login App Problem
Can't update database via client webservice.