小编Max*_*e T的帖子

是否可以将Google App Engine与Google Cloud VPN配合使用?

谷歌的文档并不是很清楚.它说(https://cloud.google.com/compute/docs/vpn/overview)

Google Cloud VPN通过IPsec VPN连接将您现有的网络安全地连接到您的Google Cloud Platform(GCP)网络

考虑到Google App Engine(GAE)和Google Compute Engine(GCE)都是Google Cloud Platform(GCP)的一部分,这意味着Google Cloud VPN适用于GAE和GCE.

此外,Cloud VNP的部分与项目控制台中的GAE和GCE处于同一级别: 在此输入图像描述

但是文档位于/ compute/docs中,它们显然不应与/ appengine/docs兼容

这里有一个描述隧道的图表,它只讨论GCE,它可以排除GAE: 在此输入图像描述

那么,GAE是否与Cloud VPN兼容,还是仅限于GCE?

vpn google-app-engine google-cloud-platform

3
推荐指数
1
解决办法
4199
查看次数

为什么在使用Java/Jersey返回404响应时会获得静态文本/ html?

我正在使用托管在Google App Engine上的Java,Jetty和Jersey 2.18(现在最新).

假设我有这样的服务

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{userId}")
public Response getUser(@PathParam("userId") String userId)
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

当我做:

    return Response.ok()
            .entity(user)
            .build();
Run Code Online (Sandbox Code Playgroud)

我正确地收到了application/json内容类型和正文.但当我这样做时:

    return Response
            .status(404)
            .entity(new ResponseModel(100, "user not found"))
            .build();
Run Code Online (Sandbox Code Playgroud)

与返回任何4XX或5XX状态相同,我收到text/html内容类型以及此HTML正文:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>404 Not Found</title>
  </head>
  <body text=#000000 bgcolor=#ffffff>
    <h1>Error: Not Found</h1>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

而不是我放入的对象.entity()

编辑:这是我的web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app
    version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.mypackage.services;org.codehaus.jackson.jaxrs</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>
                org.glassfish.jersey.server.gae.GaeFeature;
                org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;
                org.glassfish.jersey.media.multipart.MultiPartFeature;
            </param-value> …
Run Code Online (Sandbox Code Playgroud)

java google-app-engine jersey jersey-2.0

1
推荐指数
1
解决办法
1240
查看次数