spring - How to pass data from angulajs form to struts 2 action class -


here developing shopping cart.this angulajs controller.this method use send data action class using $http.post method

 angular.module("sportsstore") .constant("dataurl", "angularaction") .constant("orderurl", "angularsaveaction") .controller("sportsstorectrl", function ($scope, $http, $location,                                          dataurl, orderurl, cart) {  enter code here`$scope.data = {     };     $scope.sendorder = function (shippingdetails) {         var order = angular.copy(shippingdetails);             order.products = cart.getproducts();         console.log(order);--------------(1)         $http.post(orderurl, order)             .success(function (data) {                 //$scope.items=data;                 $scope.data.orderid = data.id;                 cart.getproducts().length = 0;                 console.log(data);---------------(2)             })             .error(function (error) {                 $scope.data.ordererror = error;             }).finally(function () {                 $location.path("/complete");             });     }}); 

using (1) console.log confirm form data , shopping cart detail stoed array.but (2) console log null action class

   package com.ai.action;    import com.ai.model.persondata;    import com.ai.model.product;    import com.ai.model.productorder;    import com.ai.model.village;    import com.ai.service.personservice;    import com.opensymphony.xwork2.action;    import com.opensymphony.xwork2.actioncontext;    import com.opensymphony.xwork2.actionsupport;     import com.opensymphony.xwork2.modeldriven;    import org.apache.struts2.dispatcher.mapper.actionmapping;    import org.slf4j.logger;    public class orderaction extends      actionsupport implements modeldriven<productorder> {--------------(1)    private map session = actioncontext.getcontext().getsession();   private logger logger = loggerfactory.getlogger(angularaction.class);    private list<productorder> order;-------------(2)    private productorder productorder;    @autowired   private personservice  personservice;  public string execute()  {     getorder();     logger.info("this method ic" ,order);     //personservice.save(personservice);----------(3)     return success; }  public list<productorder> getorder() {     return order; }  public void setorder(list<productorder> order) {     this.order = order; }  @override public productorder getmodel() {     return productorder; }   } 

how form data can use modledriven(1) or list array(2) or method.i want save form data in mysql database using hibernate(3).please me.... how form data can use modledriven(1) or list array(2) or method.i want save form data in mysql database using hibernate(3).please me....


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -