Struts 2 中操作名称的大小写敏感性
有没有一种简单的方法可以使 Struts 2 操作名称不区分大小写?目前我定义了以下操作:
<action name="printTest" class="MyClass" >
<result name="error">/WEB-INF/jsp/error.jsp</result>
<result name="input">/WEB-INF/jsp/test.jsp</result>
<result name="success">/WEB-INF/jsp/test.jsp</result>
</action>
如果用户输入 URL /app/printtest.do
而不是 /app/printtest.do
此操作不会执行。
除了 httpd 级别的 mod_rewrite 或类似的东西之外,我现在知道的唯一选择就是简单地添加相同的操作并将名称更改为 printtest。理想情况下,只需对 struts.xml
进行简单的配置更改即可。
Is there an easy way to make Struts 2 action names case insensitive? Currently I have the following action defined:
<action name="printTest" class="MyClass" >
<result name="error">/WEB-INF/jsp/error.jsp</result>
<result name="input">/WEB-INF/jsp/test.jsp</result>
<result name="success">/WEB-INF/jsp/test.jsp</result>
</action>
If the user types URL /app/printtest.do
instead of /app/printtest.do
this action is not executed.
Other then mod_rewrite on the httpd level or something like that, the only option that I know about right now is simply adding the same exact action and changing the name to printtest
. Ideally it would be a simple config change to struts.xml
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK,没有可配置选项用于不区分大小写的映射。
所以,我相信您自己已经回答了这个问题:要么使用 Apache 的 mod_rewrite,要么在配置中编写额外的映射。
您还可以编写自己的 ActionMapper,扩展 DefaultActionMapper(方法
parseNameAndNamespace()
),但我怀疑这有点矫枉过正......:-)No configurable option, AFAIK, for case insensitive mapping.
So, I believe you have answered the question yourself: either Apache's mod_rewrite, or write the extra mappings in the config.
You could also write your own ActionMapper, extending DefaultActionMapper (method
parseNameAndNamespace()
), but I suspect it would be overkill... :-)