Search Posts

Category: spring

Spring controller http post request results with 400 Bad Request

how to Spring controller http post request results with 400 Bad Request I am getting Bad Request for the folowing code : Spring Controller : @RequestMapping(value = “/getAnnotationEntitiesByText/”, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Object getAnnotationEntitiesByText(@RequestBody AnnotationRequest text) throws Exception { Collection<AnnotationItem> items = dbpediaSpotlight.annotateText(text.getText()); return items; } Angular http request : $http.post(‘knowledgeBase/api/getAnnotationEntitiesByText/’, {text: $scope.selectedEntity.description}) .then(parseResponse, printError); And my RequestBody class : public class AnnotationRequest { public String text; public […]

Best way to handle multiple async calls and scope updates in AngularJS

I’m facing a difficult situation where I have to filter out search results based on various filters on UI. Whenever I make a search, there is an api call which loads the results asynchronously. User can filter any number of times even before the results of previous search criteria loads. httpService.get(“getCREWRequests.do”, filters.getValues()).then(function(data){ $scope.requests=data; }); I’m simply updating my scope with different results from api and showing them on screen. However, api calls being asynchronous, the […]

How to attach request params in spring which is retrieved from front end?

I tried this code below…can anyone kindly help me how to pass the params to the spring method and is it a correct implementation in angularjs. @GetMapping(“/extended-registered-time”) public ResponseEntity<List<Registered_time>> getSubLeaves(@ApiParam Pageable pageable) { log.debug(“REST request to get registered time : {}”, pageable); LocalDate startDate = LocalDate.of(2018,01,15); LocalDate endDate = LocalDate.of(2018,01,24); List<Registered_time> result = ExtendedRegisteredTimeService. getSelectedRegisteredTime(startDate,endDate); return new ResponseEntity<>(result, HttpStatus.OK); } This is the frontend implementation(AngularJs) .factory(‘RegisteredTimeService’, RegisteredTimeService); RegisteredTimeService.$inject = [‘$resource’]; function RegisteredTimeService ($resource) { var […]

Angular JS and Springboot integration using rest api

I am trying to connect two different small applications. Client application is in Angular 5 and Server side is in Spring boot. Angular 5 application works fine on localhost:4200/register port and Spring boot (Server Side) works fine on port localhost:8080/api/demo. For integration I have used added a proxy.conf.json file in Angular Application. I have updated package.json script also. Followed the instruction on the website: http://javasampleapproach.com/java-integration/integrate-angular-4-springboot-web-app-springtoolsuite#5_Import_Angular4_client_project_to_SpringToolSuite. Both the projects are in same workspace. Angular project files […]

WebSocket Request (xhr_send) getting stalled (Tomcat and Apache HTTP)

My application used sockjs & Application is running on Tomcat 8 and APACHE HTTP as front end web server. I have observed that xhr_send request getting stalled and so hangs the application. On Chrome developer console, received following error when xhr_send request stalled I never received CONNECTED response. I used following code to setup websocket socket = new SockJS(applicationMainService.getUrl()+’/ws’); stompClient = Stomp.over(socket); Also received following error in Tomcat logs [org.spr[email protected]1e7904b0]: org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS […]

Spring boot template might not exist or might not be accessible by any of the configured Template Resolvers

Error resolving template “producaoPrimaria”, template might not exist or might not be accessible by any of the configured Template Resolvers I got this erros when i try to access this tamplate i using angularJs in my front-end the method that call template is this $scope.saude = function(idSistemaSelecionado) { idEntidadeSelecionada = $location.$$search.dataBase; $q.when(); if(idSistemaSelecionado ==502){ location.href = “arrecadacao/producaoPrimaria/producaoPrimaria?dataBase=” + idEntidadeSelecionada + “&app=” + idSistemaSelecionado; } }; and my appController app.config(function($routeProvider, $locationProvider,$qProvider){ $qProvider.errorOnUnhandledRejections(false); $routeProvider .when(“/producaoPrimaria”, {templateUrl:’/arrecadacao/producaoPrimaria/producaoPrimariaPaginas/inicioPp.html’, controller:’inicioPpController’}) […]

What is the best way to communicate authorization between a client and REST API?

I’m developing an application will use AngularJS for the front-end, communicating to a REST service on the backend, implemented as J2EE/Spring. The back-end services are secured through role-based authorization. In the front end of the application I would like to have the UI only allow users to perform operations for which they are authorized. The code should, for example, show/hide elements based on the user’s permissions. What is the best way to communicate the user’s […]

Spring Boot CSRF fails when handled by Load balancer

I have implemented CSRF filter in spring boot by using header based token method. When I run on single server my applications works well, when I introduce another server or request that serverd by load balancer (depends on how load balancer serves request) it fails to validate the token given by the other server. Can anyone here tell me that how can we create token for CSRF based on particular key which will be same […]

Next Page »