how to get data using angular http get from action class in struts2 project

how to get data using angular http get from action class in struts2 project  using -'angularjs'

I am developing project using angular and struts2 + maven.
this is my action class


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class AngularAction implements Action {

private Map session = ActionContext.getContext().getSession();
private Logger logger = LoggerFactory.getLogger(PersonAction.class);

private List<Village> STSarray;
private PersonService  personService;

public String execute()
    setSTSarray(personService.getAllVillage());"save method {}",getSTSarray());
    return SUCCESS;

public List<Village> getSTSarray() {
    return STSarray;

public void setSTSarray(List<Village> STSarray) {
    this.STSarray = STSarray;


Here i loaded data to
using DAO with hibernate. Data added successfully to array.
then i want to get this data to jsp page.


    <action name="angularAction" class="">
        <result type="json">
            <param name="root">personData</param>
            <param name="excludeNullProperties">true</param>
            <param name="noCache">true</param>

this is my jsp page.

<!DOCTYPE html>
<html ng-app="demo">
<meta charset="ISO-8859-1">
<title>AJAX with Struts 2 using AngularJS</title>
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/bootstrap-theme.css" rel="stylesheet" />
<script type="text/javascript" src="scripts/angular.min.js"></script>
    var app = angular.module('demo', []);

    function MyController($scope, $http) {
        $scope.getDataFromServer = function() {

                    function(data, status, headers, config) {

                        $scope.itemsdata = data;
                    }).error(function(data, status, headers, config) {

<body ng-controller="demoCtrl">
<table class="table table-striped">
<p><button data-ng-click="loadData()">
    Fetch data from server
<tr ng-repeat="item in itemsdata">

give me null.please help.

asked Oct 6, 2015 by okesh.badhiye
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.