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 中的操作


基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01