How to keep a variable in the URL when using Spring LocaleChangeInterceptor

230 views Asked by At

I have a page at this URL http://localhost:8080/SpringExercises/admin/manageMenuDetail?id=1.

I use Spring LocaleChangeInterceptor to handle languages.

When I try to change the language by clicking on a link like "?lang=it" I get an error, because id is null.

I suppose Spring turns .../SpringExercises/admin/manageMenuDetail?id=1 into .../SpringExercises/admin/manageMenuDetail?lang=it forgetting to write ?id=1

Can Spring handles this problem (for example editing the configuration file) or have I to handle it by myself?

1

There are 1 answers

0
WhatAKitty On BEST ANSWER

Do you mean you clicked a link with "http://xxx?lang=it"? If so, you should handle by yourself. eg. you could add a data-lang attribute, by that, add current href, like that: location.href = location.href + $("xx").data("lang");