How to map long REST urls in struts2 - using struts2 rest plugin

蹲街弑〆低调 提交于 2019-11-30 17:35:30

问题


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

where

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

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.


回答1:


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

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

username is user-test

order id is 64

item id is 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>


来源:https://stackoverflow.com/questions/15855831/how-to-map-long-rest-urls-in-struts2-using-struts2-rest-plugin

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