struts2 配置檔案 重定向 redirect (帶引數) 的寫法
阿新 • • 發佈:2019-02-08
對於所有重定向寫法中URL的各引數間需要以&連線,而不能以&連線!
否則報如下錯誤:
The reference to entity "arg2" must end with the ';' delimiter.
【第一種寫法】:使用Dispatch形式
[html] view plaincopyprint?- <actionname="*tAction"class="tAction"method="{1}">
-
<resultname="test"type="redirect">testtAction.action?arg1
- </action>
注意:
當使用DispatchAction時(在action標籤中的name使用了萬用字元*匹配方法名),此時type=“redirect”而不能寫成type=“redirect-action”。
此時在重定向的配置中,需要寫完全連線,即XXAction.action?...而不能寫成XXAction?...
【第二種寫法】:使用完全Action路徑形式:
[html] view plaincopyprint?-
<actionname="enterpreinfo"
- <resultname="success"type="redirect-action">
- showpreinfo?preinfo.order_number=${preinfo.order_number}&preinfo.company_name=${preinfo.company_name}
- </result>
- <resultname="error"type="redirect">
-
<param
- </result>
- </action>
注意:
因為使用了redirect-action,所以要注意不能將showpreinf?preinfo.order_number=${preinfo.order_number}寫成showpreinf.action?preinfo.order_number=${preinfo.order_number}