0

尝试访问我的 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方法中停止。

4

1 回答 1

0

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

于 2013-08-22T10:40:46.403 回答