2012-04-01 88 views
1

可能對REST一個簡單的問題...春RESTful服務GET和POST方法

如何通過GET變量的函數是在下面的代碼

@GET 
@Produces("application/json") 
@Path("/loginresult.json/{userid}/{pwd}") 
{ 
public List<SecurityBean> getAuthenticationResult(){ 
    return authenticationAPI.getAuthenticationResult(); 
} 

我wan't傳遞userid和pwd進入到getAuthenticationResult()函數的url

另外我怎樣才能傳遞POST參數?

回答

1

爲GET使用@QueryParam,

爲崗位使用@FormParam,

對Cookie的使用@CookieParam

+0

非常感謝Yogesh ...不知道爲什麼,但努力找到一個教程告訴這....真的很有幫助 – antnewbee 2012-04-10 16:04:37

+0

請問SpringFile中的@FormParam相當於什麼? – 2017-04-24 14:57:04

0

使用下面的代碼

@POST 
@Produces("application/json") 
@Path("/loginresult.json/{userid}/{pwd}") 
{ 
public List<SecurityBean> getAuthenticationResult(@FormParam("uName") String uName,@FormParam("pwd") String pwd){ 
    return authenticationAPI.getAuthenticationResult(); 
} 
+0

感謝Yogesh ....問題的第二部分...我怎樣才能傳遞POST參數? – antnewbee 2012-04-08 14:08:34

+0

你的意思是使用JavaScript或其他方式的客戶端? – 2012-04-08 14:52:58

+0

我的意思是得到GET參數你已經使用@FormParam(「uName」)...什麼shuld我用來獲得POST PARAMS? – antnewbee 2012-04-09 18:44:22