WEB开发网
开发学院软件开发Java Google App Engine for Java: 第 1 部分:运转起来... 阅读

Google App Engine for Java: 第 1 部分:运转起来!

 2009-09-17 00:00:00 来源:WEB开发网   
核心提示: 清单 1. SimpleServletAppServletpackagegaej.example;importjava.io.IOException;importjavax.servlet.http.*;@SuppressWarnings("serial")publiccla

清单 1. SimpleServletAppServlet

   
 
package gaej.example; 
 
import java.io.IOException; 
import javax.servlet.http.*; 
 
@SuppressWarnings("serial") 
public class SimpleServletAppServlet extends HttpServlet { 
  public void doGet(HttpServletRequest req, HttpServletResponse resp) 
      throws IOException { 
    resp.setContentType("text/plain"); 
    resp.getWriter().println("Hello, world"); 
  } 
} 

servlet 在 web.xml 中的 URI /simpleservletapp 下完成映射,如清单 2 所示:

清单 2. web.xml

   
 
<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE web-app PUBLIC 
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
 "http://java.sun.com/dtd/web-app_2_3.dtd"> 
 
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> 
  <servlet> 
    <servlet-name>simpleservletapp</servlet-name> 
    <servlet-class>gaej.example.SimpleServletAppServlet</servlet-class> 
  </servlet> 
  <servlet-mapping> 
    <servlet-name>simpleservletapp</servlet-name> 
    <url-pattern>/simpleservletapp</url-pattern> 
  </servlet-mapping> 
  <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
  </welcome-file-list> 
</web-app> 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:Google App Engine

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接