Guest User

Untitled

a guest
Mar 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. http://example.com/some/page?p1=11
  2.  
  3. http://example.com/some/page?p1=11&p2=32
  4.  
  5. <a th:href="@{?(p2=32)}">Click here</a>
  6.  
  7. <div th:with="currentUrl=(${#httpServletRequest.requestURI + '?' + #strings.defaultString(#httpServletRequest.queryString, '')})">
  8. <a th:href="@{${currentUrl}(myparam=test)}">click here</a>
  9. </div>
  10.  
  11. http://localhost:8080/some-page?param1=1&myparam=test
  12.  
  13. http://localhost:8080/some-page?&myparam=test
  14.  
  15. http://localhost:8080/some-page?param1=1&myparam=test&myparam=test
  16.  
  17. <div th:with="currentUrl=(${@currentUrlWithoutParam.apply('myparam')})">
  18. <a th:href="@{${currentUrl}(myparam=test)}">click here</a>
  19. </div>
  20.  
  21. @Bean
  22. public Function<String, String> currentUrlWithoutParam() {
  23. return param -> ServletUriComponentsBuilder.fromCurrentRequest().replaceQueryParam(param).toUriString();
  24. }
  25.  
  26. <span th:with="urlBuilder=${T(org.springframework.web.servlet.support.ServletUriComponentsBuilder).fromCurrentRequest()}"
  27. th:text="${urlBuilder.replaceQueryParam('p2', '32').toUriString()}">
  28. </span>
  29.  
  30. http://example.com/some/page?p1=11&p2=32
  31.  
  32. <span th:with="urlBuilder=${T(org.springframework.web.servlet.support.ServletUriComponentsBuilder)}">
  33. <span th:text="${urlBuilder.fromCurrentRequest().replaceQueryParam('p2', 'whatever').toUriString()}"></span>
  34. <span th:text="${urlBuilder.fromCurrentRequest().replaceQueryParam('p3', 'whatever').toUriString()}"></span>
  35. <span th:text="${urlBuilder.fromCurrentRequest().replaceQueryParam('p4', 'whatever').toUriString()}"></span>
  36. </span>
  37.  
  38. http://example.com/some/page?p2=whatever
  39. http://example.com/some/page?p3=whatever
  40. http://example.com/some/page?p4=whatever
  41.  
  42. <ul class="pagination">
  43. <li th:if="${currentPage > 1}"><a th:href="'/search?key=' + ${param.key[0]} + '&page=' + ${currentPage-1}">Previous</a></li>
  44.  
  45. <li th:each="i : ${#numbers.sequence( 1, total+1)}" th:class="${i==currentPage}?active:''">
  46. <a th:href="'/search?key=' + ${param.key[0]} + '&page=' + ${i}" th:inline="text">
  47. [[${i}]] <span class="sr-only">(current)</span>
  48. </a>
  49. </li>
  50. <li><a th:if="${total + 1 > currentPage}" th:href="'/search?key=' + ${param.key[0]} + '&page=' + ${currentPage+1}">Next</a></li>
  51. </ul>
  52.  
  53. th:href="@{/your/link?parameter=__${appendParameter}__}"
Add Comment
Please, Sign In to add comment