コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Does CQ provide a way to change or strip the suffix from the current URL but preserve the query params?

Avatar

Level 7

Hi,

I am looking for a way to transform the current request URL into one with a different suffix and preserve everything else.

Does CQ (or Sling) has an API for doing this? Or do I have to do it manually, maybe with some help from slingRequest.getRequestPathInfo()?

Thanks,
Behrang

1 受け入れられたソリューション

Avatar

正解者
Level 10

You can get the suffix, selectors from the URL (https://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPathInfo.html) but there is nothing to replace it. Hope you are already doing the same !

元の投稿で解決策を見る

3 返信

Avatar

Level 10

I am not aware of any such methods in APIs. you should handle it manually.

but can you explain a usecase here ?

Avatar

Level 7

We have a requirement to implement pagination and to use path variables rather than query parameters (e.g. /books/1, /books/2, etc. rather than /books?page=1, /books?page=2, etc.)

In this case, /1, /2, etc. are resolved as suffixes by CQ. So I need to extract the suffix and replace it. At the moment I am doing it manually, but it would be nice if there was a way to transform the current URL into another one with selector, suffix, etc. replaced with different values.

Avatar

正解者
Level 10

You can get the suffix, selectors from the URL (https://sling.apache.org/apidocs/sling5/org/apache/sling/api/request/RequestPathInfo.html) but there is nothing to replace it. Hope you are already doing the same !