java - How to pass a List as parameter by using ActionForward? -
I am creating a simple project using Sturts 1.0 and Hibernate. The main task of the project is to take unit number from Welcome page and then query the database for information about the unit and show results on the Index.jsp page.
Struts-config .xml DAO class But whenever I am executing this project, I go to the list via ActionForward visits Indicating an error getting an error message, please suggest any necessary changes that the project should be to execute properly. @arindam: do not attach attempts to use code below instead of list object in url Do: and & lt; Struts-config & gt; & Lt; Form beans & gt; & Lt; Form-bean name = "welcomeForm" type = "tutorial.truts.form.valcenform" /> & Lt; / Form-side & gt; & Lt; Action Mapping & gt; & Lt; Action Path = "/ ViewSetset" name = "welcomeform" type = "tutorial.Session. & Lt; forwarded name =" success "path =" / index.jsp "/> & gt; & lt; forward name =" failure "path = "/ Welcome Jsp "/> & lt; / action & gt; & lt; / action mapping & gt; public class extends viewAllAsset operation {@SuppressWarnings (" unused ") Public ActionForward executed (ActionMapping mapping, action form, HTTPSvette request Request, HTTPSRW response response) throws an exception {// http session page_session = requestMet (true); // string entity_id = page_session.getAttribute ("entity_id"). ToString (); List of & lt; Assets & gt; Result = null; string sound ्य = False; WelcomeForm wForm = (welcomeForm) form; String entity_id = wForm.getEntity_id (); Assetadata ad = New AssetDataDAO (); Results = ad.GetAssetList (entity_id); / * Get list * / list & lt; property & Gt; Asl = New Arreelist & lt; property & gt; (); for (int i = 0; i & lt; result. Size (); i ++) {asset wow = new asset (); veh SetAssetId (result.get (i) .getAssetId ()); / * Property POJO * / veh.setEntityId (result.get (i) set .getEntityId ()); veh.setAssetTypeId (result.get (i) .getAssetTypeId ()); Veh.setFuelType (result.get (i) .getFuelType ()); Asl.add (veh); } If (result! = Zero) target = "success"; Else target = "failure"; Proceeding forward = mapping.fidforward (target); Forward = new ActionForward (addParameterToUrl (forward.getPath (), "list", asl), forward.getRedirect ()); Move ahead; // Return new action (forward tag (+ + "list =" + ASL);} Private string addParameterToUrl (string url, string parameter, list & lt; asset & gt; ASL) {/ TODO auto-generated method stub Returns url + ((url.indexOf ("?") == - 1)? "?": "& Amp;") + parameter + "=" + ssl;}}
public class property data {public listing & assets; asset & gt; GetAssetList (string unit_id) throws exception {session session = zero; Ring SQL = "From asset asset where asset.entityId =: entityId and asset.isActive = 'Y'"; {Session = HibernateSessionFactory.getSession ()}; List of & lt; Asset & gt; AssetList = session.createQuery (Sql) .setString ("entityId", entity_id) .list (); Return Asset List;} Hold (Hibernate Express Hibernate Exception) {Hibernate Exception;} Hold (Exception Exception) {Exception Skip;}}}
Public class shows the ViewAllAsset operation {@SuppressWarnings ("unused") Executes public action (ActionMapping Mapping, ActionForm Form, HttpServletRequest Request, HTTPServlet Response Feedback) Exception {// HTTP session page_session = request.get session (s) ); // string entity_id = page_session.getAttribute ("entity_id"). ToString (); & Lt; Assets & gt; Result = null; String target = null; WelcomeForm wForm = (welcomeForm) form; String entity_id = wForm.getEntity_id (); Assetadado Advertising = New AssetDataDAO (); Results = ad.GetAssetList (entity_id); / * Get list * / list & lt; Property & gt; Asl = New Arrestist & lt; Property & gt; (); For (int i = 0; i
index.jsp , get the AssetsList from the requested object in the following manner:
GetAttribute ("AssetsList"); Check the above solution and tell me how it goes.
Comments
Post a Comment