2012-04-01 87 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