简体   繁体   中英

app.yaml url mapping problem

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>

and then when i press button

HTTP ERROR 404

Problem accessing /test/. Reason:

    NOT_FOUND
Powered by Jetty://

and i take a look in the auto-generated web.xml i found that

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

url-pattern should not be null

I'm new in GAE. Thanks for any advice.

/test/* will match '/test', '/test/', '/test//', etc - probably not what you intended. Try /test/.* instead.

The root cause of your problem, though, is that your YAML markup isn't valid. Instead of this:

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

it should look like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM