2016-11-04 31 views
0

以下のAPIをテストする必要があります。リクエスタに文字列配列を渡すための解決策を得られません。カンマ区切り値で試してみました、Javaのスプリングで@PathVariableに文字列配列を渡す方法

@RequestMapping(value = "/v10/{user}/alerts/alertguids/{requestors}", method = RequestMethod.GET) 
    @ResponseBody 
    @ResponseStatus(HttpStatus.OK) 
    public String[] retrieveRunnableAlertGuidsByRequestors(@RequestParam(value = "productId") final String productId, 
                  @PathVariable final String[] requestors) 
+0

が動作していません: "?のProductID =" "/ alertguids /" + "WestClipNext、マスター" + +製品。 "/ alertguids /" + "[WestClipNext、Master]" + "?productId =" + PRODUCT; –

+0

カンマ区切りの値を使用して角括弧を取り除くだけです: '/ alertguids/WestClipNext、Master?productId =" + PRODUCT' – nickmesi

+0

@UsermujM:上記のコメントで述べたように、カンマ区切りの値は機能しません。文字列全体を複数の値とみなす代わりに単一の値として返します。 –

答えて

1

[]などのある値は、私は@PathVariableとわからないが、あなたは@RequestParamを使用することができます。

例:URIは以下

@RequestMapping(value = "/v10/{user}/alerts/alertguids/{requestors}", method = RequestMethod.GET) 
    @ResponseBody 
    @ResponseStatus(HttpStatus.OK) 
    public String[] retrieveRunnableAlertGuidsByRequestors(@RequestParam(value = "productId") final String productId, 
                  @RequestParam(value = "param[]") final String[] requestors) 
関連する問題