2017-10-12 102 views
0
@RequestMapping(value = "/analyst/getcompany/{user}", method = RequestMethod.GET, produces = "application/json") 
     public String getEmail(@PathVariable String user) { 
    //logic 
    } 

請求此URI與時:REST API在Spring與參數作爲電子郵件ID給HTTP狀態406

"analyst/getcompany/[email protected]" 

這是給HTTP狀態406

我用編碼的%@ 40但電子郵件ID中的{。}正在創建問題。如何處理這個?

+0

[Spring MVC的@PathVariable的可能的複製與點(末尾添加斜線。)被截斷](https://stackoverflow.com/questions/16332092/sp​​ring-mvc-pathvariable-with-dot-is-getting-truncated) – alfcope

回答

0

此答案將幫助您。 Path variable truncate after dot - annotation

你必須在名字後面的路徑變量像

@RequestMapping(value ="/analyst/getcompany/{user}/") 

的請求

http://localhost:8080/analyst/getcompany/[email protected]/

+0

我發現建議不要使用尾部斜槓,因爲它是不可維護,如果f發現@和.c,.co被接受,但是.com給出了406. 例如。 abc @ gmail.co,abc @ gmail.ss被接受,但[email protected]不起作用,因爲後綴.com是真正的原因。 –

相關問題