泽西REST服务

时间:2016-05-20 09:53:55

标签: rest jersey

使用Jersey 1.19进行REST服务..

web.xml中的网址格式为:

<servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

在Java类中,我正在使用一种方法,该方法正在重定向到保存在web文件夹中的另一个页面。当我调用特定资源时,它看起来很好:

http://localhost:8084/userProfile/rest/user

这应该重定向到:

http://localhost:8084/userProfile/signup/index.jsp

但它重定向到:

http://localhost:8084/userProfile/rest/signup/index.jsp

通常不存在。

Java类中的方法:

@Path("/user")
public class userProfile {

    @GET
    @Produces(MediaType.TEXT_HTML)
    public Response returnForm() throws URISyntaxException {
        URI uri = new URI("/signup/index.jsp");
        return Response.temporaryRedirect(uri).build();
    }
}

如何避免重定向到包含/rest/的网址?

1 个答案:

答案 0 :(得分:0)

解决方案非常简单...... Path应该退一步 避免url-pattern / rest / *:

 ....
 URI uri = new URI("../signup/index.jsp");
 ...

THX!

相关问题