Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported for @RequestBody MultiValueMap

The problem is that when we use application/x-www-form-urlencoded, Spring doesn’t understand it as a RequestBody. So, if we want to use this we must remove the @RequestBody annotation. Then try the following: @RequestMapping( path = “/{email}/authenticate”, method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = { MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) public @ResponseBody Representation authenticate( @PathVariable(“email”) String anEmailAddress, … Read more

Limiting number of displayed results when using ngRepeat

Slightly more “Angular way” would be to use the straightforward limitTo filter, as natively provided by Angular: <ul class=”phones”> <li ng-repeat=”phone in phones | filter:query | orderBy:orderProp | limitTo:quantity”> {{phone.name}} <p>{{phone.snippet}}</p> </li> </ul> app.controller(‘PhoneListCtrl’, function($scope, $http) { $http.get(‘phones.json’).then( function(phones){ $scope.phones = phones.data; } ); $scope.orderProp = ‘age’; $scope.quantity = 5; } ); PLUNKER

Spring Test & Security: How to mock authentication?

Seaching for answer I couldn’t find any to be easy and flexible at the same time, then I found the Spring Security Reference and I realized there are near to perfect solutions. AOP solutions often are the greatest ones for testing, and Spring provides it with @WithMockUser, @WithUserDetails and @WithSecurityContext, in this artifact: <dependency> <groupId>org.springframework.security</groupId> … Read more

Difference between Observer, Pub/Sub, and Data Binding

There are two major differences between Observer/Observable and Publisher/Subscriber patterns: Observer/Observable pattern is mostly implemented in a synchronous way, i.e. the observable calls the appropriate method of all its observers when some event occurs. The Publisher/Subscriber pattern is mostly implemented in an asynchronous way (using message queue). In the Observer/Observable pattern, the observers are aware … Read more

What goes into the “Controller” in “MVC”?

In the example you suggested, you’re right: “user clicked the ‘delete this item’ button” in the interface should basically just call the controller’s “delete” function. The controller, however, has no idea what the view looks like, and so your view must collect some information such as, “which item was clicked?” In a conversation form: View: … Read more