0

I'm developing a web app with two languages, German and English. I have implemented searching on my webpage, and I want to keep track of the user's locale when searching.

How can I achieve this:

http://localhost:8080/user/search?search=pax?lang=de

instead of:

http://localhost:8080/user/search?search=pax

In my form I have:

action="/user/search"

I tried

action="<spring:message code="user.search.movie.link"/>

user.search.movie.link = /user/search or /user/search?lang=de 

but it doesn't work.

SOLO
  • 868
  • 9
  • 19
Senio Vak
  • 87
  • 4
  • 11

1 Answers1

0

Putting information in URL parameters is good in some cases*, but probably not this one. It seems likely that a user chooses their language setting once, around login time, and then rarely if ever changes it. Or it might even be set automatically. If so, language is something you might want to store in the user's session, or a persistent store like a database if you're using one. You seem to be using Spring, and I don't know a lot about their session handling, but their docs are at https://docs.spring.io/spring-session/docs/current/reference/html5/.

*: for more on this, you might want to read up on the differences between GET requests and POST requests (here's one of many SO posts on the topic). The most relevant part for you is that GETs are the ones that have visible parameters in the URL, but there are lots of other reasons to use one over the other.

SOLO
  • 868
  • 9
  • 19