Struts2 / Struts1动作调用(Struts2 / Struts1 action calls)

编程入门 行业动态 更新时间:2024-10-27 09:32:31
Struts2 / Struts1动作调用(Struts2 / Struts1 action calls)

我在使用Struts2和Struts1的应用程序上工作。 现在我想为不同的操作实现身份验证。 我想使用interceptor来检查一个action属于哪个namespace 。 我用Struts2动作包装了所有Struts1动作。 因此所有strut1-action都通过拦截器运行。

<action name="contactsList" class="com.opensymphony.xwork2.ActionSupport"> <result name="success">contactsList.do</result> </action>

问题是如果用户在浏览器中输入struts1-action,则不会调用拦截器。

我的问题:来自浏览器的动作调用与通过Struts配置调用的动作调用之间是否存在差异。 如果可能,是否可以禁止浏览器中的Struts1操作,但是从struts中允许它是允许的?

i work on an application that uses Struts2 and Struts1. Now i want to implement authentication for different actions. I'd like to use an interceptor to check to which namespace an action belongs. I wrapped all Struts1 action with Struts2 action. So all strut1-action run through the interceptor.

<action name="contactsList" class="com.opensymphony.xwork2.ActionSupport"> <result name="success">contactsList.do</result> </action>

The problem is that if a user enters a struts1-action in the browser the interceptor will not be called.

My question: Is there a difference between action calls coming from the browser and action calls called via Struts configuration. If it is possible, is it possible to disallow Struts1 actions from the browser but from within struts it is allowed?

最满意答案

你想错了方向。 Struts2中有一个Struts1插件实际上包含了Struts1动作。 所以,代码看起来像

<action name="contactsList" class="org.apache.struts2.s1.Struts1Action"> <param name="className">com.mycompany.myapp.ContactsListAction</param> <result>contactsList.jsp</result> </action>

对于您的问题,即使您的操作无效,Struts2也会返回重定向或调度到servlet的结果。 您可以对浏览器执行任何操作,但Struts会接受请求,直到您将其映射到负责对浏览器请求做出反应的URL。

You have thought in the wrong direction. There's a Struts1 plugin in Struts2 that actually wraps the Struts1 action. So, the code will look like

<action name="contactsList" class="org.apache.struts2.s1.Struts1Action"> <param name="className">com.mycompany.myapp.ContactsListAction</param> <result>contactsList.jsp</result> </action>

To your question the Struts2 return result that either redirect or dispatch to the servlet even if your action doing nothing. You could do anything with the browser but Struts will accept requests until you map it to the url where it's responsible to react on the browser requests.

更多推荐

本文发布于:2023-07-31 20:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1347306.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动作   action   calls

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!