如何在struts2中映射长REST URL - 使用struts2 rest插件 [英] How to map long REST urls in struts2 - using struts2 rest plugin
问题描述
过去几天我一直在学习使用struts2 rest插件。但没有 - 我在哪里找到了如何映射长休息网址。
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.
例如
如果我想映射如下网址:
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
用户名是用户测试
订单ID为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>
这篇关于如何在struts2中映射长REST URL - 使用struts2 rest插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!