0

In my Spring controller I'm redirecting to a view and adding two parameters param1 and param2. I want to make a div tag visible if param1 exists, so I check if param1 exists using Thymeleaf:

<div th:if="${param.keySet().contains('param1')}"> <p>something</p> </div>

And this will make the div visible...but if I add in the URL param2 too, it won't work anymore. Why? How do I make it work if I have multiple parameters? I want to use param2 for something else, take its value.

This is how my url looks like "/view?param1?param2=value". Do I need to separate the params differently?

1 Answer 1

2

in URL character ? means start getting params. You used twice ?, so second only works, and param1 it is not taken as a parameter.

If you want pass on multiple paramters in url, you should put character & between params. In your case the url will look like:

/view?param1=value1&param2=value2
Sign up to request clarification or add additional context in comments.

1 Comment

Other way to pass data in url is by path:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.