0

I build a simple app with an index.jsp (as a welcome page) and after a form-login submission directly to spring controller, i return either index.jsp or homePage.jsp (when user credentials are valid). So angular (routes, components, etc) loads for the first time at homePage.jsp.

I chose this implementation due to the fact that i am allowed to use only one ng-view and i wanted to do this only at my homePage from the time that is my main content.I would like some suggestions without using a 3d party routing such as ui-router.

1 Answer 1

0

First submit you from from JSP page to Spring Controller

<form action = "/checkUser">
        [Your input tags]
</form>

In Spring

@Controller 
public class Login{
     @RequestMapping("checkUser")
     public String checkUser(@RequestBody Map<String,Object>){
        [Check your user is Valid or not]
     [If valid]
     return "homePage.jsp"
     [else]
     return "Index.jsp"
}
}

But rather than this i personally prefer Spring Security.

Once you got on your homePage you can load all your necessary js file including the annular js files

And load your views using ng-Route

var app = angular.module('tester', 

['ngRoute']).config(function($routeProvider) {
  $routeProvider
      .when('/tests', {
          templateUrl: 'tests.html',
          controller: 'TestCtrl'
      });
});


app.controller('TestCtrl', ['$scope', function($scope){
    $scope.title = "This is a Test Page";
}]);

When You click on Tests link

<div ng-view></div>
 <a href="#/tests">Test</a>

tests.html will directly load in ng-view part

For ng-view Plunker

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.