2011-06-06 120 views
0

的app.yamlapp.yaml的URL映射問題

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中的新成員。 感謝您的任何建議。

回答

0

/test/*將匹配'/ test','/ test /','/ test //'等 - 可能不是你想要的。改爲嘗試/test/.*

問題的根本原因在於您的YAML標記無效。取而代之的是:

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

它應該是這樣的:

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