【发布时间】:2014-01-22 10:27:04
【问题描述】:
我有两个网络应用程序。当用户单击第一个应用程序中的链接时,会出现第二个应用程序。我已将用户注册 ID 作为参数添加到链接的 URL。在第二个应用程序中,我编写了一个 servlet 来捕获用户注册 ID。
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
int userId= Integer.parseInt(request.getParameter("userId"));
} finally {
out.close();
}
}
请告诉我是否应该在第二个应用程序中的任何位置提及链接的 URL。否则,servelet 从哪里获取 userId 参数。我对 java web 的东西很陌生。请帮帮我。
由于我的问题不清楚,我将在下面放另一个示例。 以下是我的服务。
@Path("/hello")
public class HelloWorldService {
@GET
@Path("/{email}")
public Response getUserDetails(@PathParam("email") String email){
String output = "User info .. "+email ;
return Response.status(200).entity(output).build();
}
下面是我的servlet。
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
String parameter= request.getParameter("email");
} finally {
out.close();
}
}
我的网址是 ...localhost:8080/RESTfulExample/rest/hello/hasi@gmail.com
我想将“hasi@gmail.com”获取到 servlet 中的参数变量。请帮我做这件事。
【问题讨论】:
-
请包含您的导入。
标签: java web-services rest servlets web