logo
Tags down

shadow

how to delete record in spring mvc using angularjs request


By : Trevisan
Date : October 15 2020, 08:10 PM
like below fixes the issue As I refereed with the docs,
User.delete is a Class action return an empty instance (with one of the additional properties below)
code :
 var app = angular.module('myApp', ['ngResource']);
 app.controller('UserController', ['$scope', '$resource',function($scope,$resource) 
    {
             $scope.deleteRec = function()
                     {
                        User = $resource(
                                'delete/:username',
                                 {method:'DELETE', params: {username: '@username'}});
                        User.delete({username: $scope.myform.username}).$promise.then(function successCallback(response) 
                        {
                            $scope.Message = response;
                        }, function errorCallback(response) {

                        });

                        $scope.myform.username = "";
                        $scope.myform.phone="";
                        $scope.myform.email="";
                        $scope.myform.address="";
                        $scope.myform.password=""; 
                      };
}]); 


Share : facebook icon twitter icon

DELETE request not allowed using CORS for cross domain request with angularjs


By : MarioFruzan
Date : March 29 2020, 07:55 AM
it helps some times Issue found!
When trying to do an OPTIONS/a DELETE request with a string that ends with an extension, such as an image, like the following request:
code :
    [HttpDelete]
    [Route("{fileName}")]
    public async Task<IHttpActionResult> Delete(string fileName)
        var lastDashPosition = fileName.LastIndexOf('-');

        var fileNameSegment = fileName.Substring(0, lastDashPosition);
        var extensionSegment = fileName.Substring(lastDashPosition+1);

        fileName = string.Format("{0}.{1}", fileNameSegment, extensionSegment);
        if (!photoManager.FileExists(fileName))
        {
            return NotFound();
        }

        var result = await photoManager.Delete(fileName);

        if (result.Successful)
        {
            return Ok(
                new {
                        message = result.Message
                    }
                );
        }
        else
        {
            return BadRequest(result.Message);
        }

Bad request errror between spring boot and angularjs by a post request


By : notexture
Date : March 29 2020, 07:55 AM
this will help I'm not familiar with Spring Boot and I don't know why you have been told to post a JSON object instead of a JSON array, but I see that you are not doing it coherently.
You wrapped your JSON array in a JSON object called list, but by specifying data: list.horses you are still only passing the embedded JSON array. Since you want to send the whole JSON object, you should specify data: list instead.
code :
public class ListModel {
    private List<HorseRaceModel> horses;

    public List<HorseRaceModel> getHorses() {
            return horses;
    }

    public void setHorses(List<HorseRaceModel> horses) {
        this.horses = horses;
    }
}
@RequestMapping(value = "/horseHistory", method = RequestMethod.POST )
public ResponseEntity<Void> getHorseHistory(@RequestBody ListModel horseRaces) throws IOException {

    System.out.println(horseRaces.getHorses().get(0).getName());

    return null;
}

The current request is not a multipart request in angularJS and Spring Rest


By : Jemobulas Tresapopan
Date : March 29 2020, 07:55 AM
hope this fix your issue The above issue is resolved by:
1) Creating a MultipartResolver bean in WebAppConfig.java as shown below:
code :
@Bean
public MultipartResolver multipartResolver() {
    CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
    return multipartResolver;
}
$http.post(uploadUrl, fd, {
            transformRequest: angular.identity,
            headers: {'Content-Type': undefined}
        });

Spring boot Thymeleaf and angularjs 1 - angularjs http request to spring controller not binding in thymeleaf view


By : Minh Tien
Date : March 29 2020, 07:55 AM
will help you Thymeleaf was server-side rendering HTML, which mean the HTML page was rendered on the server before it shown on the browser. The other side, angularJS was designed to manipulate DOM from an exisiting HTML pages that already shown in the browser.
So, you can't use thymeleaf markup to shown data that manipulated by angularJS, instead you need to use with angularJS (I assume you want print $scope.responseData) like this:

403 response for POST/PUT/DELETE request in spring boot + spring security application


By : Genea Rogers
Date : March 29 2020, 07:55 AM
wish helps you I am using spring security in my spring boot rest app. Get requests are working fine but POST/PUT/DELETE request are giving "403 Forbidden". Below is my code snippet. UI is in Angular 6 , Disable csrf in config
code :
http.csrf().disable().cors().and().....
shadow
Privacy Policy - Terms - Contact Us © voile276.org