您的位置:首页 > 编程语言 > Java开发

struts2 配置文件 重定向 redirect (带参数) 的写法

2013-07-02 22:14 429 查看
对于所有重定向写法中URL的各参数间需要以&连接,而不能以&连接!

否则报如下错误:

The reference to entity "arg2" must end with the ';' delimiter.

【第一种写法】:使用Dispatch形式

[html] view
plaincopyprint?

<action name="*tAction" class="tAction" method="{1}">

<result name="test" type="redirect">testtAction.action?arg1=${arg1}&arg2=${arg2}</result>

</action>

注意:

当使用DispatchAction时(在action标签中的name使用了通配符*匹配方法名),此时type=“redirect”而不能写成type=“redirect-action”。

此时在重定向的配置中,需要写完全连接,即XXAction.action?...而不能写成XXAction?...

【第二种写法】:使用完全Action路径形式:

[html] view
plaincopyprint?

<action name="enterpreinfo" class="preinfoBusinessAction" method="enterPreinfoSub">

<result name="success" type="redirect-action">

showpreinfo?preinfo.order_number=${preinfo.order_number}&preinfo.company_name=${preinfo.company_name}

</result>

<result name="error" type="redirect">

<param name="location">/error.jsp</param>

</result>

</action>

注意:

因为使用了redirect-action,所以要注意不能将showpreinf?preinfo.order_number=${preinfo.order_number}写成showpreinf.action?preinfo.order_number=${preinfo.order_number}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: