ct_
ct_

Reputation: 1229

java spring restful-url with semi-colon

I am currently working on a project that requires the use of a semi-colon in our restful-url scheme.

As you can imagine, we're having issues pulling this off - the underlying Java HTTPServletRequest isn't playing nicely.

Is there a way to work around this issue?

example restulf-URL:

http://service/BOB;MIKE/

Looks like Spring is only working on /service/bob - the ;MIKE gets truncated.

We've tried %3B (or %3F something like that) and it doesn't work.

Thanks in advance!

ct

Upvotes: 2

Views: 4912

Answers (3)

jebeaudet
jebeaudet

Reputation: 1603

While @Amos M. Carpenter answer is correct, here is the required configuration to turn this behavior off :

@Configuration
@EnableWebMvc
public class WebMvcConfiguration extends WebMvcConfigurerAdapter 
{
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer)
    {  
        configurer.getUrlPathHelper().setRemoveSemicolonContent(false);
    }
}

Upvotes: 3

Amos M. Carpenter
Amos M. Carpenter

Reputation: 4958

Seems this is intentional on Spring's part, but at least it's configurable.

You need to tell your handler mapping to setRemoveSemicolonContent(false) (default is true). See the Javadoc for more details.

The reason why this was done is because they apparently wanted to remove the ;jsessionid=... suffix from URIs.

Upvotes: 2

irreputable
irreputable

Reputation: 45433

this is the list of all the delimiters you can legally use in a URI:

! $ & ( ) * , ; = + ' : @ / ?

try each and see which works for you.

apparently Spring robs you of the ;. I'm not sure if that's a Servlet thing, but in any case, it sucks. A web framework should allow developers to construct ANY legal URIs.

Upvotes: 2

Related Questions