如何在 struts2 中映射长 REST url - 使用 struts2 rest 插件

2022-01-16 00:00:00 rest friendly-url jakarta-ee java struts2

过去几天我一直在学习使用 struts2 rest 插件.但是我没有找到如何映射长休息 URL.

I've been learning to use struts2 rest plugin from a past few days. But no-where I found how to map long rest URLs.

例如如果我想映射如下 URL:

For e.g. If I want to map an URL like below :

/profiles/user-test/orders/64/item/4

在哪里

username is user-test
order id is 64
item id is 4

如何将这样的内容映射到 struts2 动作?

How can I map something like this to a struts2 action ?

我在互联网上发现的只是一个正在编辑/显示的单个级别等.但是如果我想在多个级别上显示某些内容 - 那么如何进行?请指导.

All I found on internet is just a single level being edited/displayed etc. But if I want to display something on multiple-level - then how to proceed ? Please guide.

推荐答案

您可以使用 高级通配符映射,没有 REST 插件:

You can do it with Advanced Wildcard Mappings, without the REST plugin:

/profiles/user-test/orders/64/item/4

用户名是用户测试

订单编号为 64

项目 ID 为 4

此示例所需的操作配置为:

The action configuration needed for this example would be:

<action name="/profiles/{username}/orders/{order}/item/{item}" class="fooBarAction">
    <result>fooBar.jsp</result>
</action>

相关文章