Getting the query string when using Tuckey URL Rewrite

早过忘川 提交于 2020-01-03 03:16:23

问题


I have the following rule:

<rule>
     <from>^/users/(.*)$</from>
     <to last="true">/users.do$1</to>
</rule>

And I want to match the following url:

http://localhost:8077/users/?elemsPerPage=10

and redirect it to:

http://localhost:8077/users.do?elemsPerPage=10

The problem is that when the url rewriter engine finds the "?" character in the url it does not return anything else in the $1 matched parameter. Neither it adds the parameters to the query string. Any ideas?


回答1:


Finally I've found a way to solve this:

Rule:

<rule>
     <from>^/users/$</from>
     <to last="true">/users.do?%{query-string}</to>
</rule>



回答2:


There is a better way, try to add use-query-string="true" in urlrewrite

<urlrewrite use-query-string="true">



来源:https://stackoverflow.com/questions/9367232/getting-the-query-string-when-using-tuckey-url-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!