我已經寫在REST Web服務的用戶身份驗證方法的方法。成功驗證後,我想通過用戶名。我怎麼能通過它?我可以通過其他Web服務方法從登錄Web服務方法獲取值傳遞嗎?如何傳遞參數
我的登錄代碼是:
@GET
@Produces("application/json")
public Response login(@Context HttpServletRequest req,@Context HttpServletResponse res,@QueryParam("loginname")String loginname,@QueryParam("password")String password) throws IOException, ServletException
{
userDAOImpl impl = new userDAOImpl();
Mongo mongo=impl.getConnection("127.0.0.1","27017");
DB db=impl.getDataBase(mongo,"userdb");
DBCollection coll=impl.getColl(db,"userdb");
userDTO dto = new userDTO();
dto.setUsername(loginname);
dto.setPassword(password);
if(impl.checkUser(coll, dto))
{
mongo.close();
return Response.ok().build();
}
else
{
return Response.status(Response.Status.FORBIDDEN).build();
}
}
請務必標記您的問題與您正在使用的編程語言,或者更具體的標籤 – 2011-04-13 06:48:03