如何在普通 Struts2 下配置一个包,在 Struts2 下配置另一个包 +休息插件?
我有一个使用 Struts2 的现有应用程序,该应用程序的一部分位于“/portals/.../A”和“/portals/.../B”下。配置文件看起来像这样:
<struts>
<package name="portals/*" extends="struts-default">
<action name="A" ...> ...</action>
<action name="B" ...> ...</action>
</package>
</struts>
在我添加 Rest 插件 jar 之前,它工作得很好。它似乎接管并忽略设置。
理想情况下,我想要的是保持门户不变并添加一个名为“rest”的新包,该包将由 Rest 插件处理。
http://localhost/portals/* ....普通struts2
http://localhost/rest/* ... struts2 + rest 插件
问题是“如何?”。
我添加了一些休息插件设置,例如:
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
但旧的操作仍然被破坏。
I have an existing application using Struts2 for a section of the app served under "/portals/.../A" and "/portals/.../B". The configuration file looks something like this:
<struts>
<package name="portals/*" extends="struts-default">
<action name="A" ...> ...</action>
<action name="B" ...> ...</action>
</package>
</struts>
That works fine until I add the Rest Plugin jars. It seems to take over and ignore the settings.
Ideally, what I want is to keep portals untouched and add a new package called "rest" that would be handled by the Rest Plugin.
http://localhost/portals/* .... plain struts2
http://localhost/rest/* ... struts2 + rest plugin
The question is "How?".
I added some rest-plugin settings like:
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
but the old actions are still broken.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有看到有人在包名称中放置星号。您的包实际上可能是“portals/*”,
这意味着
“/portals/*/”需要在调用其中的操作之前。
那么对于所有相关人员来说都会更清楚
IE:“.../portals/*/A.action”将调用操作 A。无论如何,如果您只是调用 say:您可以在操作中使用通配符, 。其作用是捕获 url 的一部分,让您动态调用方法/类并设置与通配符匹配的参数,详细信息请参见: http://struts.apache.org/2.1.8.1/docs/wildcard-mappings.html 但是据我所知这不能应用于包。
I have not see someone place an asterix in a package name. Your package as such might actually be "portals/*"
meaning
"/portals/*/" would need to precede a call to an action within.
IE: ".../portals/*/A.action" would call action A. Anyways it is much clearer for all involved if you just call say:
You can have wild cards in actions. What this does is captures parts of the url letting you dynamically call methods/classes and set parameters matching that wild card for details see: http://struts.apache.org/2.1.8.1/docs/wildcard-mappings.html however as far as I know this can not be applied to packages.