Struts2 pass parameters to action in different webapp(Struts2 将参数传递给不同 webapp 中的操作)
问题描述
我使用 Struts 2.3.16.3.我希望 webapp 1 的操作将参数传递给 webapp 2 中的操作.在 webapp 1 的 struts.xml 中,我定义了以下结果:
I use Struts 2.3.16.3. I want an action from webapp 1 to pass parameters to an action in webapp 2. In the struts.xml of webapp 1 I define the following result:
<result name="success" type="redirect">
<param name="location">http://localhost:8080/Webapp2/index.action</param>
<param name="testParam">testValue</param>
</result>
当结果等于成功"时,我希望我的浏览器将我重定向到此网页(webapp2 中的一个页面):
I expect my browser to redirect me to this webpage (a page in webapp2) when the result equals 'success':
http://localhost:8080/Webapp2/index.action?testParam=testValue
但是,我的浏览器会将我带到:
However, my browser takes me to:
http://localhost:8080/Webapp2/index.action
完全忽略参数.
如果我将结果更改为将所有内容都包含在位置参数中,那么它可以工作,但是您会看到使用多个参数会变得非常笨拙:
If I change my result to have everything inside the location param then it works, but you can see this gets very clunky with multiple params:
<result name="success" type="redirect">
<param name="location">http://localhost:8080/Webapp2/index.action?testParam=${testValue}</param>
</result>
这会正确地将我的浏览器重定向到该网址:
This correctly redirects my browser to the url:
http://localhost:8080/Webapp2/index.action?testParam=testValue
为什么第一种方法不起作用?
Why does the first method not work?
推荐答案
如果location
开头是http:
, https:
, mailto:
, file:
, ftp:
然后它被用作使用 response.sendRedirect()
重定向的最终位置.在这种情况下,使用 <param>
标记的结果中的参数将被忽略.
If the location
starts with http:
, https:
, mailto:
, file:
, ftp:
then it's used as a final location to redirect using response.sendRedirect()
. Parameters in the result using <param>
tag in this case are ignored.
这篇关于Struts2 将参数传递给不同 webapp 中的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Struts2 将参数传递给不同 webapp 中的操作


- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01