问题标签 [actioncontext]
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.
javascript - How to add data in JavaScript and bind it to jQuery grid
I have a form whose value get stored in the database on click of submit
button.
Also there are 4 fields whose data is to be displayed into the struts2-jquery-grid. I first used a temporary table to save values and display those values in the grid. But this approach isn't correct as the values remain in the table even if the user doesn't click on submit.
So is there a way to temporary store the data of 4 fields into the array and display in the grid and then when user submits the data the values from the array(grid) are stored into the database.
java - Struts2 JUnit ActionContext 对象
StrutsActionContext
正在null
测试中。
使用 Struts2 JUnit 插件我有以下测试:
两个相关的类如下:
我正在尝试"application"
用ActionContext
.HashMap
值是在测试中设置的,但是一旦代码在BaseAction
值中执行,则null
. 这里有类似的问题(链接),但在我的情况下答案不正确。
是否有不同ActionContext
的被创造?如果是这样,如何将变量传递给BaseAction
?
struts2 - Struts2中ActionMapper、ActionProxy、ActionInvocation、ActionContext对象的作用域?
ActionMapper
当, ActionProxy
, ActionInvocation
,的对象ActionContext
在 Struts2 应用程序中创建时,谁能描述我。由于我是 Struts2 框架的新手,我对这些对象的范围感到非常困惑。
java - StrutsSpringTestCase - 几个上下文 - 如何按顺序正确实例化它们
我正在为使用 JUnit 的 Struts2、Spring、Hibernate 的项目编写集成测试用例。
我的测试类扩展了StrutsSpringTestCase
. 应用程序需要登录/会话来调用任何操作。以下是代码:
initAction()
方法:
在使用此方法之前,它会加载所有配置文件。struts.xml
jpaContext.xml
,beans.xml
等。
我的 Action 类CustInfo
实现ServletRequestAware
了,它有一个方法getActionName
,如下所示:
当我调用时会调用它result = proxy.execute();
。所以请求失败。
问题1:为什么会返回null
?我认为ServletActionContext
是自动启动的,所以它应该返回一个值。但它不是。如果它没有初始化,初始化的正确位置在哪里以及如何初始化?
getActionProxy
我在通话后尝试了以下操作。但它仍然没有工作。
问题2:要设置会话,之前getActionProxy()
,我必须打电话,
再一次,之后getActionProxy
设置会话。我想,这里有问题。
问题 3:看起来,这里有几个上下文在起作用applicationContext
:ActionContext
ServletContext
和ServletActionContext
。
当我的测试类扩展StrutsSpringTestCase
类时,我猜applicationContext
是初始化了。但我不确定其他情况。在哪里初始化它们?
编辑:
对源代码的进一步调查揭示了一个问题。当我调用时ServletActionContext.getActionMapping()
,在内部调用它ActionContext
的get()
方法。
context
是一个对象的映射,它在其中寻找struts.actionMapping
不存在的键的值。所以,返回null
。但不知道为什么它在那里。它不是空的。它有其他键/值。
java - 为什么使用 ServletRequestAware 而不是 ServletActionContext?
要在 Struts 2 中获取 servlet 请求,我们可以使用ServletRequestAware
或ServletActionContext
。但是,在特定的 Internet资源中,被告知ServletRequestAware
应该使用 . 而不是ServletActionContext
.
这是否与ServletActionContext
在多线程环境中将成为共享资源的事实有关,或者这背后是否有任何其他原因?
java - 为什么我们不能通过 ServletActionContext 使用 execAndWait 拦截器?
我必须在 Struts2 中的选定操作上使用加载栏,并且正在使用ServletActionContext
,但正在获取NullPointerException
.
如果我execAndWait
从 xml 配置文件中删除拦截器,它工作正常。
有人建议我使用SessionAware
. 为什么这样 ?
有什么解决办法吗?
java - 在 home.jsp 中设置 Actioncontext 的 session 属性
默认情况下,如果我有一个 struts 主页,它是 home.jsp,它可以是:
如您所见,我已经指出第 X 行,我想直接在 actioncontext 的 Session 属性中设置 test2 参数,而不是在 valuestack 中。我想在 view.jsp 中将此值打印为 -<s:property value="%{#session.test2}" />
但输出是 test2 本身。如何正确地做到这一点?我上面使用的那个似乎肯定是错误的:(
任何帮助将不胜感激
谢谢贾延德拉
spring - 将对象直接存储到 ValueStack/ActionContext 的目的是什么?
根据我的研究,我发现诸如<s:set>
,<s:push>
或通过创建一个标签<s:bean>
能够直接插入对ActionContext
or的引用ValueStack
。这让我很困惑,因为你为什么不能有一个专门的地方来存放所有东西?可能只是把所有东西都放在里面,ActionContext
因为它基本上是作为一个ServletContext
.
更令人困惑的是,如果您想访问 中的值,则ValueStack
必须使用 Struts 标记,<s:property>
但如果值只是存储在 中ActionContext
,则只需使用#value
OGNL 提供的前缀。
有人可以帮我解决这个问题吗?当我使用 Spring 时,我相信我需要的一切(请求、会话、applicationContext)都ServletContext
在我的网页中,并且要访问我网页上的这些值,我可以只使用$
前缀来访问上下文中的任何内容。
spring - Struts2 和 Hibernate - 在 Servlet 外部访问 ActionContext.getContext().getSession()
我尝试在 2 种不同情况下访问 Struts (Struts2) 操作之外的 ActionContext.getContext() 并且我得到了不同的结果,关于我尝试的位置:
- 来自 CurrentTenantIdentifierResolverImpl 的 CurrentTenantIdentifierResolver 的(我的)实现,它是一个 Hibernate 接口 --> KO(结果为空)
- 来自 AbstractRoutingDataSource 的一个(我的)AbstractDataSource 实现,它是一个 Spring 接口 --> OK
我找到了另一个解决方案来让我的 CurrentTenantIdentifierResolverImpl 使用 ThreadLocal 工作,但是:
- 为什么它适用于 Spring 而不适用于 Hibernate?
- 为什么我不能访问可以访问我的 ThreadLocal 的 ActionContext(也可以是 ThreadLocal)(我设置的与 ActionContext 完全一样,相同的位置,相同的数据)?
CurrentTenantIdentifierResolverImpl :应该给使用的租户,以便休眠可以提供与良好数据库的连接。
AbstractRoutingDataSource :相同但由 Spring 处理
当我查看两种情况下的堆栈时,我可以看到:
- AbstractRoutingDataSource 已将我的 Servlet (HomeAction) 放入堆栈
- CurrentTenantIdentifierResolver 在堆栈中没有我的 Servlet (HomeAction)
这是堆栈跟踪。
休眠:
春天:
java - Struts 2 中的 Java 应用程序可以管理多少个会话?
我正在开发事务管理应用程序,并且正在使用 Struts2。我在内部使用了一个会话来设置和获取值,例如
在应用程序中使用这样的会话是否有任何限制或缺点?