Spring的错误请求400

时间:2013-08-22 10:06:30

标签: json spring-mvc

尝试访问我的REST API时收到HTTP错误请求。问题是Spring没有给调试提供太多信息。

网址为http://localhost:8080/webapp/network/v1/jobs.json?callback=jQuery203040624934318475425_1377165238418&sEcho=1&iColumns=1&sColumns=&iDisplayStart=0&iDisplayLength=10&mDataProp_0=id&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&_=1377165238419

控制器:

@Controller
@RequestMapping("/network/v1/jobs")
public class JobsController {

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResponseEntity<JQueryDatatablesPage<Job>> list(
            @RequestParam int iDisplayStart, @RequestParam int iDisplayLength,
            @RequestParam int sEcho, @RequestParam String search) {
        ...
    }
}

在我的pom文件中,我有杰克逊:

    <!-- Jackson JSON Mapper -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>

json扩展名用于返回JSONP:

<filter>
    <filter-name>jsonpCallbackFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>jsonpCallbackFilter</filter-name>
    <url-pattern>*.json</url-pattern>
</filter-mapping>

调试器在过滤器中停止但我仍然收到错误请求,调试器不会停在list方法中。

1 个答案:

答案 0 :(得分:0)

愚蠢的错误参数search不在网址中。刚刚添加了@RequestParam(required = false) String search)