Showing posts with label ajax call. Show all posts
Showing posts with label ajax call. Show all posts

Thursday, 28 January 2016

Failed to load resource: the server responded with a status of 406 (Not Acceptable) in spring mvc ajax call

This error can be solve by these tricks .

1. use @EnableWebMvc with  spring 4.0 or above.

 @Controller
@EnableWebMvc
@RequestMapping(value = "/articles/action",  produces="application/json")
public class UserController {

}


2. use  produces="application/json" in @RequestMapping


3. add these dependency or jar if missing

<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.2.3</version>
    </dependency>