我有一个带有 Web 服务的 J2EE 应用程序,如下所示
http://servername/service?task=getFile&id=25
如何将这些类型的网址转换为
http://servername/service/getFile/25
http://servername/service/getFile/26
等等?
请提出您的建议。
最佳答案
您可以使用UrlRewriteFilter
为了实现这一目标。您只需编写重写规则,类似于 mod_rewrite。 For example :
<rule>
<from>^/products/([0-9]+)$</from>
<to>/products/index.jsp?product_id=$1</to>
</rule>
关于java - 将 GET 方法 url 转换为逻辑永久链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2314644/