How to pass model attributes from one Spring MVC controller to another controller?

I use spring 3.2.3 and here is how I solved similar problem. 1) Added RedirectAttributes redirectAttributes to the method parameter list in controller 1. public String controlMapping1( @ModelAttribute(“mapping1Form”) final Object mapping1FormObject, final BindingResult mapping1BindingResult, final Model model, final RedirectAttributes redirectAttributes) 2) Inside the method added code to add flash attribute to redirectAttributes redirectAttributes.addFlashAttribute(“mapping1Form”, mapping1FormObject); 3) … Read more

accessing HttpContext.Request in a controller’s constructor

instead of putting your HttpContext.Request.IsAuthenticated in Controller level you should put it in Controller Base class that will be inherited in all of your controller with an override method of OnActionExecuting() method. In your Controller base you should have public class BaseController : Controller { protected override void OnActionExecuting(ActionExecutingContext ctx) { base.OnActionExecuting(ctx); ViewData[“IsAuthenticated”] = HttpContext.Request.IsAuthenticated; … Read more

Angularjs, passing scope between routes

You need to use a service since a service will persist throughout your app’s life. Lets say you want to save data pertaining to a user This is how you define the service : app.factory(“user”,function(){ return {}; }); In your first controller: app.controller( “RegistrationPage1Controller”,function($scope,user){ $scope.user = user; // and then set values on the object … Read more

Display a view from another controller in ASP.NET MVC

Yes. By default, ASP.NET MVC checks first in \Views\[Controller_Dir]\, but after that, if it doesn’t find the view, it checks in \Views\Shared. The shared directory is there specifically to share Views across multiple controllers. Just add your View to the Shared subdirectory and you’re good to go. If you do return View(“~/Views/Wherever/SomeDir/MyView.aspx”) You can return … Read more