【问题标题】:app.yaml url mapping problemapp.yaml url映射问题
【发布时间】:2011-06-06 05:20:41
【问题描述】:

app.yaml

application: cloudymovie
version: 1
runtime: java

welcome_files:
  - test.jsp

handlers:
  - url: /test/*
  - servlet: com.test.TestLexerServlet
  - name: testlexer

test.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<form action="/test/" method="get">
    <input type="submit" value="Go">
</form>
</body>
</html>

然后当我按下按钮时

HTTP ERROR 404

Problem accessing /test/. Reason:

    NOT_FOUND
Powered by Jetty://

我看看自动生成的 web.xml 我发现了

<servlet-mapping>
    <servlet-name>com.test.TestLexerServlet</servlet-name>
    <url-pattern>null</url-pattern>
</servlet-mapping>

url-pattern 不应为空

我是 GAE 的新手。 感谢您的建议。

【问题讨论】:

    标签: java google-app-engine yaml


    【解决方案1】:

    /test/* 将匹配 '/test'、'/test/'、'/test//' 等 - 可能不是您想要的。请改用/test/.*

    不过,问题的根本原因是您的 YAML 标记无效。而不是这个:

    handlers:
      - url: /test/*
      - servlet: com.test.TestLexerServlet
      - name: testlexer
    

    应该是这样的:

    handlers:
      - url: /test/*
        servlet: com.test.TestLexerServlet
        name: testlexer
    

    【讨论】:

      猜你喜欢
      • 2011-01-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 2016-03-01
      • 2017-10-02
      • 2012-10-08
      相关资源
      最近更新 更多