Is Spring annotation @Controller same as @Service?

No, they are pretty different from each other. Both are different specializations of @Component annotation (in practice, they’re two different implementations of the same interface) so both can be discovered by the classpath scanning (if you declare it in your XML configuration) @Service annotation is used in your service layer and annotates classes that perform … Read more

AngularJS custom filter function

You can use it like this: http://plnkr.co/edit/vtNjEgmpItqxX5fdwtPi?p=preview Like you found, filter accepts predicate function which accepts item by item from the array. So, you just have to create an predicate function based on the given criteria. In this example, criteriaMatch is a function which returns a predicate function which matches the given criteria. template: <div … Read more

Web API Routing – api/{controller}/{action}/{id} “dysfunctions” api/{controller}/{id}

The route engine uses the same sequence as you add rules into it. Once it gets the first matched rule, it will stop checking other rules and take this to search for controller and action. So, you should: Put your specific rules ahead of your general rules(like default), which means use RouteTable.Routes.MapHttpRoute to map “WithActionApi” … Read more

How to pass parameters to a partial view in ASP.NET MVC?

Here is another way to do it if you want to use ViewData: @Html.Partial(“~/PathToYourView.cshtml”, null, new ViewDataDictionary { { “VariableName”, “some value” } }) And to retrieve the passed in values: @{ string valuePassedIn = this.ViewData.ContainsKey(“VariableName”) ? this.ViewData[“VariableName”].ToString() : string.Empty; }

What does “The type T must be a reference type in order to use it as parameter” mean?

If you look at the definition of DbSet<TEntity>: public class DbSet<TEntity> : DbQuery<TEntity>, IDbSet<TEntity>, IQueryable<TEntity>, IEnumerable<TEntity>, IQueryable, IEnumerable, IInternalSetAdapter where TEntity : class Because it has a type constraint that the generic type must be a class then you must initialize it with a type that also matches this condition: public class GenericRecordController<T> : Controller … Read more

How to rename rails controller and model in a project

Here is what I would do: Create a migration to change the table name (database level). I assume your old table is called corps. The migration content will be: class RenameCorpsToStores < ActiveRecord::Migration def change rename_table :corps, :stores end end Change your model file name, your model class definition and the model associations: File rename: … Read more

ASP.NET MVC – Should business logic exist in controllers?

Business logic should really be in the model. You should be aiming for fat models, skinny controllers. For example, instead of having: public interface IOrderService{ int CalculateTotal(Order order); } I would rather have: public class Order{ int CalculateTotal(ITaxService service){…} } This assumes that tax is calculate by an external service, and requires your model to … Read more

Multiple controllers with AngularJS in single page app

What is the problem? To use multiple controllers, just use multiple ngController directives: <div class=”widget” ng-controller=”widgetController”> <p>Stuff here</p> </div> <div class=”menu” ng-controller=”menuController”> <p>Other stuff here</p> </div> You will need to have the controllers available in your application module, as usual. The most basic way to do it could be as simple as declaring the controller … Read more

Which is better, return “ModelAndView” or “String” on spring3 controller

There is no better way. Both are perfectly valid. Which one you choose to use depends which one suits your application better – Spring allows you to do it either way. Historically, the two approaches come from different versions of Spring. The ModelAndView approach was the primary way of returning both model and view information … Read more