2013年9月28日星期六

struts2 redirect transmission parameters of the problem .




// struts2 重定向 传参数问题。
<action name="addInfo" class="infoAction" method="add">

  <result name="success" type="redirectAction">

                 <param name="actionName">listInfo</param>

                 <param name=" ">${info.id}</param>

                 <param name=" ">${info.title}</param>

             </result>           //param name=" "应该怎么填写?

</action>


<action name="listInfo" class="infoAction" method="list">

<result name="success">/infolist.jsp</result>

</action>


//infolist.jsp

<s:iterator id="c" value="infos" status="s">

<s:property value="id" /> //id是自增的,别说用转发 type=chain

​<s:property value="title" />

</s:iterator>


------ Solution ------------------------------------- -------


you put your own needs to think clearly , to redirect queries need to add data transfer over you ? Pass in the past is really useful ? The data do you use to add a list of query parameters?

If you must pass, direct
****. action? info.id = $ {info.id} & info.name = $ {info.name}

------ Solution - -------------------------------------------
do you want to use in such a way to achieve it, you just want to add is successful, the listinfo page and then flew just added successfully traverse the data is right, then you first add it again without success after the investigation would be finished . . . .
------ For reference only -------------------------------------- -
landlord does not know what the intention is , why you wrote . If you really do not know to look struts-config.xml file , strut2 underlying Which constants related with this approach , like that actionName is how come the same !!!
------ For reference only - --------------------------------------


My intention is clear ah , click Save execute addInfo.Action. Yet addInfo redirected to listInfo all data that is traversing . But is stuck in this step do not know what this fill , try a variety of results did not solve .
------ For reference only -------------------------------------- -
/ / param name = "" how should I fill out ? parameter names , is that you need to define , and then in the action (infoAction) define and generate parameter set, get method, then you can directly access the parameter value via the parameter



------ For reference only ---------------------------------- -----
this need not redirect directly in the add method in the finish after their own logic to the info assignment , result write
/ infolist.jsp
------ For reference only -------------- -------------------------

action is defined objects , collections, no attributes , attribute separately defined in the entity class medium . That at this time / / param name = "" should be how to fill ? Or in the action must be written on the id title attribute get set way to do this ?

------ For reference only ---------------------------------- -----
representation never knew this kind of approach , novice !
------ For reference only ---------------------------------------


You did not understand what I mean, fill in the page data is complete, click the button to perform this action when addInfo will be redirected to listInfo. The problem is to redirect / / param name = "" what to write ? .
------ For reference only -------------------------------------- -

  
You did not understand what I mean, fill in the page data is complete, click the button to perform this action when addInfo will be redirected to listInfo. The problem is to redirect / / param name = "" what to write ? .   course listInfo is to traverse all the data that is added after completion redirected to traverse the data page.
------ For reference only -------------------------------------- -

action is defined objects , collections, no attributes , attribute separately defined in the entity class. That at this time / / param name = "" should be how to fill ? Or in the action must be written on the id title attribute get set way to do this ?   
 

parameter names can be arbitrarily defined , has also been defined sid, stitle, general, or define meaningful . You always want to touch hands . Do not be afraid , things are playing out ,
------ For reference only ---------------------------- -----------

<param name="info.id">${info.id}</param>
<param name="info.title">${info.title}</param> 

------ For reference only --------------------- ------------------
indicates weakness ah ~ ~ ~ ~
------ For reference only ---------------------------------------

this way wrong.
------ For reference only ---------------------------------------
10 floor impossible wrong , to make the $ {info.id} has a value , you must add a set method for the info object , you must have it to get the value of the get method , you see how to do ,
------ For reference only ---------------------------------------

  
you put your own needs to think clearly , to redirect queries need to add data transfer over you ? Pass in the past is really useful ? The data do you use to add a list of query parameters?   
  
If you must pass, direct   
****. action? info.id = $ {info.id} & info.name = $ {info.name}   
 
Thank you, big brother to the reminder , thought, after adding data does not need to redirect page spread list , I encountered a problem , add the data and click the Save page jump list , but added pages have a primary key auto-incremented ID, how to spread the list page .
with type = chain not, but after I click save , on the current page , and then click Connect to list page traverse action can get increment ID, but so unfriendly .
------ For reference only -------------------------------------- -
solve the problem, add a method to return the struts return list () method that is able to get the database traversal ID, but why add the action in struts.xml I wrote type = chain jumps to list the action, why not get the ID , I do not know why.

没有评论:

发表评论