问题标签 [struts2-interceptors]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
cookies - 如何在 struts2 拦截器中验证 cookie
先说一下场景
- 我正在为我的应用程序使用 struts2
- 在这里,我想检查特定 cookie 的有效性(如果用户选中了让我保持登录复选框,则该 cookie 已保存)
- cookie 的目的是,如果用户提供有效的 cookie,他将被视为登录用户。
- 现在我想在拦截器中验证 cookie,因为这将在许多操作中重新使用。
问题:我使用了 struts2 提供的CookieInterceptor,它将 cookie 存储在 ActionContext 中。 但是我将如何在拦截器中访问该值。或者更确切地说,在拦截器中使用 ActionContext 值并通过拦截器的后端服务来验证它们是一种好方法。
提前谢谢。
struts2 - 插入延迟后未使用 execAndWait Struts 拦截器下载文件
我的代码从后端服务器下载文件。由于我们将检索数以百万计的记录,因此我们使用了 Struts2execAndWait
拦截器。为了测试这一点,我们插入了 30 秒的延迟。我能够在不插入延迟的情况下下载文件(测试数据非常小),但插入后,我再也没有得到文件。日志显示,由于等待文件中的 5 秒,动作类被重复执行<meta-refresh>
,即使输入流被填充。
这种行为的原因可能是什么?
代码设置:
Struts.xml:
PS:我还没有在百万数据集上测试过这段代码。测试数据仅包含少量数据。
java - 谁调用Struts 2中拦截器的intercept方法
我正在使用 Struts2 拦截器,容器在咨询配置管理器 ( struts.xml
) 后为相关操作类创建操作代理。现在是执行拦截器链的时候了,我有一个简单的问题——到底是谁调用了Myinterceptor
类中的拦截方法。
据我了解,它由相应动作类的actionproxy调用,与spring AOP中的操作相同,proxyfactorybean执行类似的操作来调用类的建议(切入点)。
但我没有任何文件来支持这一点。请让我知道我是否正确。
java - 使用 Struts 2 中的拦截器进行身份验证后的登录重定向
我有一个登录页面。登录请求可以来自多个操作类。验证用户后,我必须将其重定向到前一个操作类(登录请求来自该操作类)。我正在使用拦截器来执行此操作。但我错过了一些东西,它无法正确重定向。
这是我的代码:
我的struts.xml
:
PathFinderAction
可以请求登录。loginAction
用于验证用户。
java - 上传文件时出现 NullPointerException
上传文件时,我收到以下错误:
索引.jsp
上传文件.java
struts.xml
java - 找不到引用名称 jsonValidationWorkflowStack 引用的拦截器类
在我的 Struts2 应用程序中,我有以下操作struts.xml
我正在扩展json-default
in ma struts.xml 文件,并在我的类路径中使用 struts-json 插件。但是在运行应用程序时,我收到如下错误
找不到引用名称 jsonValidationWorkflowStack 引用的拦截器类
任何关于出了什么问题的想法,任何帮助表示赞赏。
我已经关注了这个链接
web.xml
java - 拦截器没有在 Struts 中被调用
我的拦截器(验证)在操作之前或之后没有被调用。任何想法如何让它工作?
注意:每次调用默认拦截器时。
java - Action errors are not shown on the JSP
I have tried adding action errors in the Action class and printing them on the JSP page.
When an exception occurred, it is going into the catch block and it is printing "Error in inserting the Exception, Contact the Admin", in console.
In the catch block, I've added it with addActionError()
, and I've tried printing it in jsp page...
but the message is not shown in jsp page.
What I may be missing or doing wrong ?
Struts mapping:
Action class:
JSP code for printing action errors:
java - Properties not being set in prepare method
I am using Struts2 and an action implementing the Preparable
interface.
When I submit the form, action properties are not being set in prepare()
method of action. I get the values in the action method (eg. execute()
), but they are empty in the prepare()
method.
How can I get the properties set before running the prepare()
method ?
struts2 - 在 Struts 2 中停止长时间运行的进程
我executeAndWait
在 Struts2 应用程序中实现了 Interceptor,它运行良好。有没有办法通过拦截器停止这个长期运行的过程?我可以限制执行操作的最长时间吗?